Question
i want to create a class in C++ called date that has 3 integers. month, day, year and have a constructor for the class to
i want to create a class in C++ called date that has 3 integers. month, day, year
and have a constructor for the class to initialize those parameters
do not include the class (.h) in seperate file, all the codes in one file the .cpp
have a setter and getter functions for the day the month and year,
then display the dates of today,
all the above info are already coded in the following code:
#include
int main() { int day, month, year; // Create a Date object with the constructor and initialize the data members Date today(2, 3, 2023); // Display the date cout << "Today's date is: "; today.displayDate(); }
so the output after you run the program should be like :
Today's date is: 2/3/2023
now do not do leap year, i was not asking about leap mess
read the instructions below :
Create a class called Date that includes three pieces of information as data membersa month (type int), a day (type int) and a year (type int). Your class should have a constructor with three parameters that uses the parameters to initialize the three data members. For the purpose of this exercise, assume that the values provided for the year and day are correct, but ensure that the month value is in the range 112; if it isnt, set the month to 1. Provide a set and a get function for each data member. Provide a member function displayDate that displays the month, day and year separated by forward slashes (/).
everything you read so far is already done in the above code
what i want you to do is to :
Write a test program that demonstrates class Dates capabilities.
which means in the same code above , where you can see i already implemented the if statement for the month , if the user enter month that is in negative or zero or more than 12, because we only have 12 months : 1,2,3,4,5,6,7,8,9,10,11,12 in the year
to default it back to month 1
while the day and year is to not be tested whatever number the user input is acceptable
to implement this add the few extra line of codes needed to let the user enter new date after displaying the date of today
and if the user input month that are negative or zero or 13 or more then it will default the month only to 1 ,
your previous code was defaulting everything to 1 says OOPS 01/01/01
this is not acceptable please understand what i am asking you to do
read everything over and over ill you understand what i am asking you to do kindly
so the output after you run the program should be like :
Today's date is: 2/3/2023
please enter the updated date:
(month day year) format : -5/03/2023
the month is not within acceptable criteria defaulting to 1
01/03/2023
I POSTED THIS QUESTION 3 TIMES , THIS IS THE 4TH ATTEMPT, WASTING MY MONEY ON THIS CHEGG WEBSITE, BECAUSE I AM WASTING MY ATTEMPTS,
I HAVE LIMITED ATTEMPTS
3 TIMES AND IS TILL AHEVNT GOT WHAT I WANTED
GOD HELP ME
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started