Starting from:
$30

$24

Homework #5 Solution

Write a program that calculates the charge for babysitting. The program uses military time: 1100 is 11am, 1800 is 6pm, 2400 is 12midnight, 1730 is 5:30pm. Note that the low-order digits represent minutes, while the upper digits represent hours (for example, there is no such time as 1970 because there are not 70 minutes in an hour). Hours and charging rates are as follows:
    • The sitter only works from 1800 to 2400.
    • Total service time must be positive (end time must be greater than start time).
    • The charge from 1800 to 2130 is $2/hour. The charge from 2130 to 2400 is $4/hour.
    • The final charge is in whole dollars. If the calculated charge (in float form) has $0.30 or more as the fraction of a dollar, the charge should `be “rounded” up to the next whole dollar. If the fractional dollar charge is less than $0.30, just drop that part of the charge. For example, $35.20 would end up being $35, and $22.42 would end up being $23.
Input will be two integers, indicating the times that the service started and ended. Your program should make sure input is valid. Output should be the total charge.
Hint: Note that 1234/100 is 12 (the upper 2 digits), and 1234%100 is 34 (the lower two digits). This can be used to separate the input values into hours and minutes.
The executable program Gold05.exe demonstrates what your program should do, except that it outputs the result more than one time because I used more than one solution approach (you only need to produce one solution).
You should turn in (in a pocket folder): this assignment/grading sheet (write your name in the space below), your statement of completeness, a structure chart of your program (matching your “outline” comments), and a full printout of your program.  All documents should be appropriately labeled.  You should also place a “soft” (electronic) copy of your main.cpp file (in a properly named folder) into the private folder of your FTP site.

More products