CS 242, Section 002 | Sonoma State University | Fall, 2021 |
Discrete Structures for Computer Science
|
||
Instructor: Henry M. Walker
Lecturer, Sonoma State University |
Submissions are to be submitted on paper, with one submission from each assigned pair of students, unless a student has explicit (written) permission from the instructor.
Both partners should collaborate on every problem, and both names should be at the top of the first page. Since this is a collaborative effort, both partners should agree that the work represents their agreement in the correctness of the answers, and the same grade will be recorded for each assignment.
Problems for each section (each bullet item in the assignment) should begin on a new page, and problems within a section should be in numeric order.
If a problem requires the writing of a Python program, then the submission should include a printout of the code, a listing of appropriate test runs, and a statement regarding how the test runs provide sufficient evidence to conclude the program works properly.
Each problem from Rosen's text should be identified with its section number and problem number. Each problem written out as a separate bullet point should be identified in a phrase or sentence, so it is clear which question is being answered.
When a problem asks for a conclusion, the solution must include both a statement of the conclusion and an argument justifying that conclusion.
Answers should be placed in Section and problem order, so the first page (more if needed) should give answers for the problems in the first assignment bullet. Answers for subsequent bullets should be in the order of the bullets on the Assignment sheet.
Although the rules of this course allow the use of sources beyond the discussions of a student pair, any outside references (e.g., from the textbook, from Web sources, from discussions with others, etc.) must be fully cited.
Challenge Problem—Computing a Babysitter's Fee
A baby sitter charges $10.75 per hour until 9:00 pm (while the kids are still up), $8.50 per hour between 9:00 pm and midnight, and $12.25 per hour after midnight (since late night baby sitting interferes with morning classes).
Write a Python program that reads four integer values (the sitter's starting time in hours and minutes and the ending time in hours and minutes) and computes the sitter's fee. Assume all times are between 6:00 pm and 6:00 am, and hours should be specified as being between 0 and 12 (inclusive). Hours outside the range of 0 to 12 should be considered invalid.
The following table may clarify allowed time values for this problem.
Starting | Starting | Ending | Ending | Starting | Ending |
---|---|---|---|---|---|
Hour | Minutes | Hour | Minutes | Time | time |
8 | 0 | 3 | 30 | 8:00pm | 3:30am |
6 | 0 | 0 | 45 | 6:00pm | 12:45am |
12 | 0 | 6 | 0 | 12:00am (midnight) | 6:00am |
Programming Note: You may NOT use loops or recursion in this program.
create July 22, 2021 revised August 24, 2021 |
|
For more information, please contact Henry M. Walker at walker@cs.grinnell.edu. |