CS 160

Lab 6

February 2/22/05

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. You will prompt the user for 3 items:

With these three integer 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 193 in your text.  Control the flow, the person should have it's own Person class that holds the variables, and 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 Your TA or by a consultant. 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, 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. You will have nested if/else statments inside if/else statements.

Get as much as you can done, and if you don't finish you will be checked on what you have done, and you will need to finish it before next week. Your TA will tell you what he wants turned in. 

Here are some example runs:

How old are you?
35
Are you married (1=yes, 2=no)?
2
How many times a week do you date?
2
You date just the right amount

How old are you?
15
Are you married (1=yes, 2=no)?
2
How many times a week do you date?
0
You're too young to date

How old are you?
24
Are you married (1=yes, 2=no)?
2
How many times a week do you date?
12
You date too much

How old are you?
24
Are you married (1=yes, 2=no)?
1
How many times a week do you date?
3
You're married, you shouldn't be dating

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