Write a program that performs the following tasks:

1) Read in a month and determine the number of days in the month. If the month is February,

prompt the user for a year and determine if the year is a leap year to output the correct number

of days. (A leap year is divisible by four, except for years with are multiples of 100, which are only

leap years if they are also divisible by 400). Your program should accept the month as a 1 or 2

digit number, a three letter abbreviation for the month, or a full month.

2) Given someone’s brithday in the form mm/dd, m/dd, mm/d or m/d generates their sign and

random advice (from atleast four possibilities).

3) Write the truth tables for the following boolean expressions:

a. A || B && C

b. (A || B) && ! (A && B)

4) Strictly extra credit: Write a compatibility test for an online dating service.

a. Have the two people enter their names.

b. Calculate points as follows:

i.If the two names are the same, they get -1 points and you do not have to check

anymore

ii.If the names of the same length add 2 points

if the length of one name is 1 more than the other add one point

iii.If the first letters are the same add 1 point

iv.If the last letters are the same add 1 point

v.If the last letter of one name is the same as the first letter of the other add 1

point. (do the same for both names)

vi.Add the int values of the first letter of each name. take the value mod 3 and add

it to the total.

vii.Add the int values of the second letter of each name. take the value mod 4 and

add it to the total.

c. You should have anywhere from -1 to 11 points. Print off the points and a snarky

comment appropriate for each one. Be sure to include their names in the message. Use

this list to determine which comment to display:

i.11 points à comment 1

ii.8 to 10 points à comment 2

iii.5 to 7 points à comment 3

iv.2 to 4 ponts à comment 4

v.0 or 1 points à comment 5

vi.-1 points à comment 6

Sample test runs on the next two pages

  • 9 years ago
Java Program
NOT RATED

Purchase the answer to view it

blurred-text
  • attachment
    code.java
  • attachment
    assignment5.java