CS 230 Spring 2005                                       Lab Example

 

Goal – Create Test Cases and Test Program

 

here's the application description:

 

The NJ State Police are working on a new program in conjunction with the EZ Pass system. This program is a simplification. It should allow the user to process a number of cars in a batch (“event driven loop”). For each car, the program should get from the user for the time spent, miles traveled and the speed limit on the stretch of the Garden State Parkway traveled - (in real life these would be obtained via the scanning process)). The program should calculate and display the speed and calculate and display any fine owed (see details below). The program should update summary information including how many cars were speeding, the percent of cars speeding, average speed, the total fines charged, and fine averages.

 

Details:

1.      The schedule for fines is as follows:

·        On or under speed limit - no fine

·        less than or equal to 5 mph over the limit - $20 fine

·        more than 5 mph and less than or equal to 10 mph over the speed limit -

-        fine is $20 plus $2 for each mph over the speed limit.

·        more than 10 mph and less than or equal to 20 mph over the speed limit -

-        fine is $20 plus $4 for each mph over the speed limit.

·        more than 20 mph over the speed limit -

-        fine is $50 plus $5 for each mph over the speed limit.

2.      If the speed limit on the stretch of highway is 65 or higher, then the above fines are DOUBLED.

3.      The program should ensure that the user types in valid data (i.e. numeric data; positive number of miles and minutes, speed limit no lower than 35, and no higher than 70).