Out lab 3

Due March 1rst

To Do

You are to write a program that takes in a date (take it in as a string from the user) and then prints out what day of the year it is. For example:
Give a date in the format xx/xx/xxxx (12/31/2005):  <= program output
02/05/2005                                          <= user input
The date : 02/05/2005 is the 36 day of the year     <= program output
The program should have the following methods in a DateCalculator class:

Output

Here are five sample outputs of my program running. The first was improper format from the user, second as a bad day from the user, the third was an error because the user swapped the month and the day around, the fourth Worked perfectly, and the fifth didn't do the month in two digits.
Give a date in the format xx/xx/xxxx (12/31/2005):
12311996
Invalid Date, needs to be in the form xx/xx/xxxx


Give a date in the format xx/xx/xxxx (12/31/2005):
05/45/2005
Invalid day, must be between 1-31


Give a date in the format xx/xx/xxxx (12/31/2005):
31/12/1999
Invalid month, must be between 1-12


Give a date in the format xx/xx/xxxx (12/31/2005):
05/15/2005
The date : 05/15/2005 is the 135 day of the year


Give a date in the format xx/xx/xxxx (12/31/2005):
3/15/2006
Invalid Date, needs to be in the form xx/xx/xxxx

Hint:

My program also had a begin method, my main was only two lines long.

 public static void main(String [] args)
  {
     DateInterp di = new DateInterp();
     di.begin();
    }

In my begin method I called each method I listed above and the methods that were checking for errors returned an int that interpreted the error. Here is my begin method:
 public void begin()
   {  
      int ok = getDate();
      if(ok!=0){
      	ok = parseDate();
      	if(ok==4){
         	calculateDate();
      	    printResults();
         }
         else if(ok==1) System.out.println("Invalid year");
         else if(ok==2) System.out.println("Invalid month, must be between 1-12");
         else System.out.println("Invalid day, must be between 1-31");
      }
   }

Assignment due the beginning of lab class March 1rst