Mainstring args system out println system out println

Info icon This preview shows pages 2–3. Sign up to view the full content.

main(String[] args){ System. out .println( "********************************************************* ********" ); System. out .println( "Program Name: Date.java" ); System. out .println( "Programer's Name: Eric Errichiello" ); System. out .println( "Program Description: Increments a Date then will go to next month if invalid date " ); System. out .println( "********************************************************* **********" ); try { DisplayDate (11, 18, 2012); System. out .println( "Date object constructor for date: " + print ()); for ( int i = 1; i < 41; i++){ nextDay (); System. out .println( "Incremented Date:" + print ()); } } catch (Exception e) { } } public static void DisplayDate( int month, int day, int year) throws Exception{ cal = new GregorianCalendar(); cal .set(Calendar. MONTH , month - 1); cal .set(Calendar. DATE , day); cal .set(Calendar. YEAR , year); if ( cal .get(Calendar. YEAR )!=year || cal .get(Calendar. MONTH ) + 1 !=month || cal .get(Calendar. DATE )!=day){ System. out .println( "Invalid Date" ); } } public static void nextDay(){ int date = cal .get(Calendar. DATE ); cal .add(Calendar. DATE , 1); if (date==31 && cal .get(Calendar. DATE )==1) System. out .println( "Day 32 is an invalid date. Set back to day 1." ); if (date==30 && cal .get(Calendar. DATE )==1); System. out .println( "Day 31 is an invalid date. Set back to day 1" ); if (date==29 && cal .get(Calendar. DATE )==1); System. out .println( "Day 30 is an invalid date. Set back to day 1" ); if (date==28 && cal .get(Calendar. DATE )==1);
Image of page 2

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

System. out .println( "Day 29 is an invalid date. Set back to day 1" ); } public static String print(){ return String. format ( "%d/%d/%d" , cal .get(Calendar. MONTH ) + 1, cal .get(Calendar. DATE ), cal .get(Calendar. YEAR )); } }
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.
  • Fall '12
  • Unknown
  • Subroutine, System.out.println, Eric Errichiello

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern