CS120 Project 1

A simple date calculator

Overview. Fifty days after May 15, what date will it be? In this assignment, you will write a simple calculator to answer these questions.

Technical details. Your program should read in three numbers via three calls to a Scanner‘s nextInt method:

  • First, the number of the month, 1 for January through 12 for December.
  • Next, the date, from 1 to 31.
  • Finally, a number of days.

Your program should output a string like:

1 day after August 2 is August 3.

or

10 days after May 28 is June 7.

Note that I will expect your program to print the name, and not the number, of the months.

For this assignment, you can assume that all of the numbers are in their sensible, natural ranges: that all of the numbers will be positive, that your program will not be given the 13th month, nor the 34th day of a month, nor some date like June 31 (June has only 30 days). You can also disregard leap years, and assume that February has 28 days. Finally, you can assume that the number of days will not “wrap around” from December back to January.

You should use only the Six Things Java Can Do to solve this project. Do not work ahead to arrays or methods.

Do not give a Java package declaration in your class (and if you do not know what that means, do not worry about it!).

Testing these assignments. I will write a program to test your work on several different dates and intervals. Be sure to read in input in exactly the order described here; it is in this order that my tester will provide input to your program. Do not expect other interaction with the user except for what thie specification describes.

Submission instructions. Submit the single, plain-text file DateCalc.java to D2L by 8:30am on Thursday, September 28. Remember to comply with the style guidelines for CS120 Java work.

Avoid plagiarism. The course syllabus has further details about our expectations of academic integrity. In particular: You may not copy code from any other source and claim it as your own. You may not share any of your code with any other student for use in completing any of these assignments.

Links to: CS120 homepage