Question: Provide answer to this practice excercise using Eclipse or Java; Below are the directions Following is the entire code: import java.util.Scanner; public class DateThirdTry {

Provide answer to this practice excercise using Eclipse or Java;

Below are the directions

Following is the entire code:

 import java.util.Scanner; public class DateThirdTry { private String month; private int day; private int year; //a four digit number. public void writeOutput( ) { System.out.println(month + " " + day + ", " + year); } public void readInput( ) { boolean tryAgain = true; Scanner keyboard = new Scanner(System.in); while (tryAgain) { System.out.println("Enter month, day, and year"); System.out.println("as three integers:"); System.out.println("do not use commas or other punctuations."); int monthInput = keyboard.nextInt( ); int dayInput = keyboard.nextInt( ); int yearInput = keyboard.nextInt( ); if (dateOK(monthInput, dayInput, yearInput) ) { setDate(monthInput, dayInput, yearInput); tryAgain = false; } else System.out.println("Illegal date. Reenter input."); } } public void setDate(int month, int day, int year) { if (dateOK(month, day, year)) { this.month = monthString(month); this.day = day; this.year = year; } else { System.out.println("Fatal Error"); System.exit(0); } } public void setMonth(int monthNumber) { if ((monthNumber  12)) { System.out.println("Fatal Error"); System.exit(0); } else month = monthString(monthNumber); } public void setDay(int day) { if ((day  31)) { System.out.println("Fatal Error"); System.exit(0); } else this.day = day; } public void setYear(int year) { if ( (year  9999) ) { System.out.println("Fatal Error"); System.exit(0); } else this.year = year; } public boolean equals(DateFifthTry otherDate) { return ( (month.equalsIgnoreCase(otherDate.month)) && (day == otherDate.day) && (year == otherDate.year) ); } public boolean precedes(DateFifthTry otherDate) { return ( (year = 1) && (monthInt = 1) && (dayInt = 1000) && (yearInt  

Provide answer to this practice excercise using Eclipse or Java; Below are

CODE:

public static void main(String[] args) {

// TODO Auto-generated method stub

DateThirdTry date = new DateThirdTry();

date.readInput();

date.writeOutput();

}

the directions Following is the entire code: import java.util.Scanner; public class DateThirdTry

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!