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

Create a class called Date that includes three pieces of information as automati

ID: 3838576 • Letter: C

Question

Create a class called Date that includes three pieces of information as automatic properties: a month (type int), a day (type int) and a year (type int).

Your class should have a constructor that initializes the three automatic properties and assumes that the values provided are correct. You should provide a method DisplayDate that displays the month, day and year separated by forward slashes (/). Write a test app named DateTest that demonstrates class Date’s capabilities.

The user inputs in the screen shot should be the same as the following output.

Hint: the method DisplayDate:

You need to know that auto-implemented property Month, Day, and Year implicitly creates an instance variable for the month, day, and year respectively

CAWINDOWSsystem3 Your Name, Student Number The initial date is: 10/1/2016 Date with new values is: 2/27/2017 Press any key to continue

Explanation / Answer

Here is your program: -


using System;
using System.Collections.Generic;


namespace Dates
{
public class DateTest
{
public static void Main(string[] args)
{
Date d = new Date(10,1,2016);
Console.WriteLine("Your Name, Student Number");
Console.WriteLine();
Console.Write("The Initial Date is: ");
d.DisplayDate();
Console.WriteLine();
d.setDay(27);
d.setMonth(2);
d.setYear(2017);
Console.Write("Date with new value is: ");
d.DisplayDate();
}
}
  
public class Date
{

int month;
int year;
int day;
  
public Date(int month,int day,int year) {
this.month = month;
this.year = year;
this.day = day;
}
  
public void setMonth(int month) {
this.month = month;   
}
public void setYear(int year) {
this.year = year;   
}
public void setDay(int day) {
this.day = day;   
}
public int getMonth() {
return this.month;   
}
public int getYear() {
return this.year;   
}
public int getDay() {
return this.day;   
}
  
public void DisplayDate() {
Console.Write("{0}/{1}/{2}",this.month,this.day,this.year);   
}
}
}

Sample Output: -

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