CS 160

Lab 10

March 3/23/04

Write your own code for the following assignment:

Develop a Java program that will determine whether a person needs to date more, less, or never date and then at the end print out the overall results. You will prompt each new entry for 3 items:

With these three values you should write a program that outputs one of three things:

Criteria for your output (this is not factual, I'm not looking for a debate):

First sketch out your logic on a piece of paper, you might want to use a flow chart like on page 187 in your text.  Control the flow, the person should have it's own Person class that holds the variables, as well as the static variables for the summary at the end. Then you should call methods that help with the output. After you get a sketch of what you want to do on paper have it checked by Tim or by a consultant (they're not quite as picky about their names). After you get that OK'd start writing the program.

Get the married part done first, you can check the married part and have a single if - else statement (do not use ==, you have to use a string compare), if they are married print "you shouldn't date" if they are not married you will have an else statement that will handle the rest of the code. Inside that else you will check to see if they are under 18, if they are under 18 you will print "you should not date", if over 18 you will have another else that checks the rest of the variables.

After a new person has entered their data you will prompt them if there is another person's data you want to add. If they give you a yes recirculate through the above. If they say no you should print out the stats and then exit. The stats will consists of the number of entries, average age, average dates per week, amount of married people. These stats should be kept in static variables. Mr. Tim Gradl will tell you what he wants turned in. 

Here is a example run of my program:


I would like to point out that this is not factual, I'm married and still go on dates....with my wife (she frowns on dates with other people).