Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a class called Date that includes 3 instance variablesa month (type int), a day (type int), and a year (type int). Provide a constructor

Create a class called Date that includes 3 instance variables—a month (type int), a day (type int), and a year (type int). Provide a constructor that initializes the 3 instance variables and assumes the values provided are correct. Provide a set and a get method for each instance variable. Provide a method displayDate that displays the month, day, and year separated by forward slashes(/). Write a test application named DateTest that demonstrates class Date’s capabilities.

I can not figure out what I am doing wrong.... Here is what I have so far

// -- Data Class
//CSIS 212-

public class DateClass
{
int month;

int day;

int year;

public DateClass(int month, int day, int year) {

this.month = month;

this.day = day;

this.year = year;

}

public int getMonth() {

return month;

}

public void setMonth(int month) {

this.month = month;

}

public int getDay() {

return day;

}

public void setDay(int day) {

this.day = day;

}

public int getYear() {

return year;

}

public void setYear(int year) {

this.year = year;

}

public void displayDate() {

System.out.println(month + "/" + day + "/" + year);

}

}

public class DateTest {

public void main(String[] args) {

Date day = new Date(06,22,2020);

day.displayDate();

System.out.println("Month: " + day.getMonth());

System.out.println("Day: " + day.getDay());

System.out.println("Year: " + day.getYear());

day.setMonth(06);

day.setDay(22);

day.setYear(2020);

day.displayDate();
}
}
}

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

More Books

Students also viewed these Programming questions

Question

How did the authors avoid the post hoc fallacy?

Answered: 1 week ago

Question

Patients are kept waiting two hours for appointments.

Answered: 1 week ago