Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

3.15 (Date Class) Create a class called Date that includes three instance variab

ID: 3639406 • Letter: 3

Question

3.15 (Date Class) Create a class called Date that includes three instance variables—a month (type int), a day (type int) and a year (type int). Provide a constructor that initializes the three instance variables and assumes that 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.

Explanation / Answer

public class Date { // fields private int month; private int day; private int year; // constructor public Date(int month, int day, int year){ this.month = month; this.day = day; this.year = year; } public void setMonth(int month){ this.month = month; } public void setDay(int day){ this.day = day; } public void setYear(int year){ this.year = year; } public int getMonth(){ return month; } public int getDay(){ return day; } public int getYear(){ return year; } public String displayDate(){ return month + "/" + day + "/" + "/" + year; } }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote