CS 1401 Assignment #5

Date Assigned: Thursday, September 29, 2005 or Friday, September 30, 2005.

Due Date: correspondingly, Thursday, October 6, 2005, or Friday, October 7, 2005, before the beginning of your lab section.

Goals: to learn mathematical functions like exp(x), log(x), conditions, and logical expressions.

Points: This assignment is worth a total of 20 points. No late assignments will be accepted, but credit will be given for partially completed assignments turned in on time.

Assignment: To celebrate latest football victories, CS students decided to follow the good old tradition of soaking each other with the drinks at the CS parking lot. The problem is that this creates a fertile ground for bacteria. To avoid an epidemic, we must clean up as soon as the bacteria concentration reaches the danger level D=0.97. To help, we need to design a software tool that would predict the bacteria contamination at the parking lot.

For each celebration, we know the time t of the celebration, we know the initial concentration C, and we know the rate a with which bacteria multiply. This means that if there was no cleanup, then at time T, the concentration is equal to C(T) = C * exp(a*(T-t)). If this predicted concentration exceeds the danger level D, this means that there was a cleanup, so the resulting concentration is C(T) = 0. In this case, we must return not only the resulting concentration level (C(T) = 0), but also the time c when the cleanup occurred. This time can be found from the equation C * exp(a*(c-t)) = D, i.e., as c = t + (1/a) * ln(D/C).

Structure: Define a class ParkingLot in which each object (parking lot) is characterized by two parameters: the bacteria concentration C and the rate a with which bacteria multiply. Make sure that your description includes:

Define a class Celebration in which each object (individual celebration) is characterized by its initial state (an object of type ParkingLot) and celebration time t. This class should include the following methods:

Named constants such as the danger level D should be defined in the class Celebration.

All readings from the user and all printing to the screen should be in the main method of the application class.

The application class should do the following:

Deliverables: as announced in the labs.