CS 157 Spring 2002                     Assignment 7 – Developing and using test cases for a program                            50 points

 

Assigned: 03/15/2002

Due: 03/21/2002 at the start of class

 

Pre-Lab (Do Before Lab): None

 

Main Assignment:

            There is a buggy version of a program, named redmond7wrong.java, available in the assignments page of my WWW site (Look under Assignments at www.lasalle.edu/~redmond/teach/157 ). Use Internet Explorer - we had trouble with Netscape, and save it do your disk – make sure there is no html in the file. The program is described below. However, this version has bugs. Your mission is to test it, so you can notify the developer which test cases provide incorrect results. The skills learned here can also be useful for testing your own programs.

 

What I want from you is (either hand in via paper or e-mail to redmond@lasalle.edu  is fine):

 

1)     The answer to: How many test cases (runs through the program) are necessary to thoroughly test the program? EXPLAIN YOUR ANSWER!!! 

2)     Tell me what runs you did. Indicate which test cases gave correct results and which exposed flaws in the program.

 

You DO NOT have to determine what the problem(s) are or how to fix them. The focus of this assignment is on catching bugs.

 

Ok, 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 ask the user how many cars will be processed in a batch. Then, for each car, the program should ask the user for the speed of the car 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 then display the speed. The program should then calculate the fine (see details below). If the person is to be fined, the program should display a bill for the person (see below). After processing all of the cars in the batch, the program should display a report including how many cars were speeding, the percent of cars speeding, the total fines charged, and averages (details below).

 

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. positive number of cars, mph, speed limit no lower than 35, and no higher than 65). Loop to ensure they cannot in any circumstances get invalid data into your calculations.

 

Note that everything above was taken from a description of a task for a previous class. It is not your task. Your task is to use test cases to gather evidence about problem(s)!! The skills learned here can also be useful for testing and debugging your own programs.