CSC 160 Fall 2006 - Homework 5
Assigned Oct 26, due SUNDAY Nov 5, revisions due SUNDAY Nov 12


Read the first page of this short but informative article on What is a Computer Program?"
Read Chapter 7 (up to the end of page 93) in Simply Scheme.
Read Section 3 of How to Design Programs.
Read PSP Chapter 3 (given out in class on Tuesday 10/10).
Complete the Log Sheet at the end of the handout, while doing HW5. This is the new log you will be submitting with each homework for the rest of the semester.

Directions
  • Read these directions carefully before starting the assignment.
  • The assignment may be done alone or in pairs using the ideas in the Pair Programming article.
  • You cannot pair up with the same person more than once during the semester.
  • Whenever defining a Scheme function, you must show all six steps of the Design Recipe introduced in class on Thursday 10/5.
  • If you are defining auxiliary functions, you need to show the 6 steps of the Design Recipe for each of the auxiliary functions, as well as the 6 steps of the Design Recipe for the main (or primary) function.
  • When writing a program, the name of the main (or primary) function is the name of the program. Use sensible names of your choice for auxiliary functions.
  • If an auxiliary function is not predefined, but you have seen it written before (e.g. in class, on a reading assignment, or on a previous programming assignment), just copy the function definition (no contract, skeleton, etc.) into the top of your Definitions Window.
  • For each question, to receive full credit, you must use at least one auxiliary function that is not predefined in DrScheme or any of the teachpacks. However, functions that we have written before (including area-of-disk, query, counterchange, checkerboard, mirror-horiz, and mirror-vert) do count as auxiliary functions.
  • Please complete this assignment in the Simply Scheme mode of DrScheme.
  • If you do not fully understand any of the directions above or the questions below, please e-mail me as soon as possible.

    The Assignment
    Answer any 2 of the following 3 questions.
    1. Write a Scheme program tiling. It consumes an image and returns a 2x2 arrangement of that image, where the original image is in the top left and lower right corners, and the horizontal reflection of the function is in the top right and lower left corners.
    --Hint: Think about function definitions you have already seen, either in the lecture slides or in previous assignments.

    2. Write a Scheme program total-cost. It consumes the selling price of a house and the amount of the down payment, then produces the grand total paid by the buyer at the end of the loan.
    --The following terms apply. The mortgage is financed for 30 years. The base interest rate is a simple 8.0% per year. Extra fees total $1000.
    --Hints: the principal is the difference between the selling price and the down payment; only the principal is used in calculating the interest; the total cost of the loan is the selling price plus the interest plus any fees.

    3. Write a Scheme program front-to-back that takes in a sentence. It takes off the first word of the given sentence and puts it back on as the last word, with its first letter moved to the end of the word.
    --For example, (front-to-back '(It is sunny.)) "should be" '(is sunny. tI)
    --Note that the above example does not count as one of your three examples.
    --Also, note for this function, you can assume the sentence it takes in consists only of words and that it has two or more words, and that each of those words has two or more letters in it.
    --In addition, for this question only, do not worry about case sensitivity, so if your expected answer is '(hello its due sunday) and you get '(Hello its due sunday) or '(HELLO ITS DUE SUNDAY), that is fine. --Hint: You can create an auxiliary function that moves a word from the front to the back of a sentence. You can also create an auxiliary function that moves a letter from the front to back of a word. Then "use" either or both of these functions to write the main function, front-to-back.

    Submitting your Assignment
  • Please submit your Definitions Window, your Interactions Window, and your Log Sheet, using the Digital Dropbox in the Tools menu on Blackboard. Be sure to include your first and last name!
  • The file name for the Definitions Window needs to be "hw5[section][LastName]Def.scm" where:
    [section] is replaced by -01 for the 3:05 class and -02 for the 4:30 class, and
    [LastName] is replaced with your last name.
    For example, if I were submitting this assignment and I were in the 4:30 class, I would name the file "hw5-02WittensteinDef.scm".
  • Similarly, the file name for the Interactions Window must to be "hw5[section][LastName]Int.scm"
  • And, the file name for the Log Sheet must be "log5[section][LastName].xls".
  • If you use an incorrect file name, up to 5 points may be deducted.
  • You must submit only one Definitions Window and only one Interactions Window which includes the entire assignment. Otherwise, up to 5 points may be deducted.
  • The Interactions Window MUST include testing for each function.


    Grading Purposes Contracts Examples Skeletons Definitions Testing
    Question 1 or 2 or 3 /4 /6 /6 /6 /18 /5
    Question 1 or 2 or 3 /4 /6 /6 /6 /18 /5
    Log /10

    Last Modified: 11/9/06