Year Program
Write a program that uses main and two user-defined methods. Both methods use dates, but neither method is dependent upon the other method. In main, you will have the user input the date in one input in the form mm dd yyyy (use a space between each number). You will save the month, day, and year parts in 3 separate variables.
You will send these values to a convertdays method that will return the date in the form of one long integer using the following formula: your long year will be the sum of the year multiplied by 10000, the month multiplied by 100, and the day. This is a formula used to put the date in a form that can be sorted (we will not be sorting dates, just putting it into a form that can be sorted). Back in main you will print this labeled long integer.
You will then call a leap method (making sure you are sending what value(s) it needs) that will return if it is a leap year using the following formulas: a year is a leap year if it is divisible by 400 or if it is divisible by 4 and not divisible by 100. The leap method will return the boolean result to main, where the proper message will be printed telling if it is a leap year or not, including the printing of the year.
Use the following data to run your program four separate times:
10 16 1900
8 21 2000
5 17 1836
11 17 1873
Document your program with at least name, exercise number, and at least 4 lines explaining what the program does. You will also add comments to at least 5 individual lines in the program (comment lines that might not be totally obvious to a novice programmer).


0 comments