Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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  

image text in transcribed

CODE:

public static void main(String[] args) {

// TODO Auto-generated method stub

DateThirdTry date = new DateThirdTry();

date.readInput();

date.writeOutput();

}

image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spomenik Monument Database

Authors: Donald Niebyl, FUEL, Damon Murray, Stephen Sorrell

1st Edition

0995745536, 978-0995745537

More Books

Students also viewed these Databases questions