Java Lab #5: Methods

The program you created for Lab #4 has a main method that is fairly large and unmanageable. In this lab you will created a modified version of the Lab #4 program that is organized better by splitting the original code into several smaller methods.

  1. Move the code that accepts the user's input into its own method. The method should leave the values provided by the user in static fields of the main class where they can be accessed by other methods.

  2. Create a method that advances the date by one day. Be sure to give it a reasonable name. Change the main program so it calls the input method and then calls the date advance method multiple times (in a loop). The body of the loop should now be only one line.

  3. To simplify the date advance method, think about breaking out certain aspects of it into separate methods as well. For example a method that returns boolean that checks if the current date is a leap year might be useful.

  4. Add some input validation to your input method. Use a loop to ensure that the method won't return until some sort of valid input is provided.

Turn in just your final version of the program. Be sure to include appropriate comments! Be sure to include your name at the top of the file!