Question: Modify the following program import java.io . * ; class Datem { int month,day,year; void displayDate ( ) { System.out.print ( month + /

Modify the following program
import java.io.*;
class Datem
{ int month,day,year;
void displayDate()
{
System.out.print(month+"/"+day+"/"+year);
}
void setDate(int num1, int num2,int num3)
{ month = num1;day = num2; year = num3;}
}
class XXXLb210-5a
{public static void main(String args[])throws IOException
{
Datem anvsy=new Datem();
BufferedReader in = new BufferedReader (new InputStreamReader(System.in));
System.out.print("Please Enter the information for your anniversary
");
System.out.print("Enter the month: ");
int anv_mn = Integer.parseInt(in.readLine());
System.out.print("Enter the day of the month: ");
int anv_day = Integer.parseInt(in.readLine());
System.out.print("Enter the year: ");
int anv_yr = Integer.parseInt(in.readLine());
anvsy.setDate(anv_mn,anv_day,anv_yr);
System.out.println();
System.out.print("The Anniversary Date is on ");
anvsy.displayDate();
}
}
Above is a program that enters a date in to the system.
Copy this information in to a file (*.java)
Using comments indicate the behaviors of the class date.
Using comments indicate the attributes of the class date.
Using comments indicate the instance of the class date.
Modify this program to display the date as Month-Day-Year
Add the mutator methods for month, day and year [setmonth(), setday() & setyear()]
Add the accessor methods to return month, day and year [getmonth(), getday() & getyear()]
Add another behavior to the class that will display the 1 year anniversary date(no changes to the date).(and call from main() function)
Add a default constructor to the class that will set up the date to Jan 1,2020
Add a parameterized constructor to the class that will set up the date to the 3 passed values
Add a parameterized constructors (2 values passed) to the class that will call the parameterized (3 value) to set the values to month day and the year to 2023
Create three more instances of the new class Datem and assign values and output the data, one year anniversary to the screen

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 Programming Questions!