Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 #include using namespace std; // creating a class named Date with three parameters on month, day and year , all are integer types class Date { //private access specifier for those integers private: int month, day, year; //public access specifiers with constructor to initialize the previously mentioned parameters public: // Constructor must be same name as the class and with no retuen or return type with three parameters, adn isnide the constructor we must put the if statement for the month Date(int m, int d, int y) { month = m; day = d; year = y; // Ensure that the month value is in the range 1-12 if (month < 1 || month > 12) { month = 1; //if the date is set above 12, it will automatically set it to 1 } } //For the purpose of this exercise, assume that the values provided for the year and day are correct // setter member function for the integer day void setDay (int d) { day = d; } //getter memebr functionn for the integer day int getDay() { return day; } //setter memebr function for integer year data member void setYear(int y) { year = y; } //getter member function for integer year data memebr int getYear() { return year; } // setter function for month integer data member void setMonth(int m) { month = m; } // getter function for month integer data member int getMonth() { return month; } // Member function to display the date in the format: month/day/year //idea was refrenced from w3schools.com void displayDate() { cout << month << "/" << day << "/" << year << endl; //formatting the output using "/" } };

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

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

Visualizing Health And Healthcare Data Creating Clear And Compelling Visualizations To See How Youre Doing

Authors: Katherine Rowell ,Lindsay Betzendahl ,Cambria Brown

1st Edition

1119680883, 978-1119680888

Students also viewed these Databases questions