Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Page of 3 - ZOOM + HW_3 - Struct Date Write a program that prompts the user for the month, day and year. If

C++

image text in transcribed

image text in transcribed

image text in transcribed

Page of 3 - ZOOM + HW_3 - Struct Date Write a program that prompts the user for the month, day and year. If the date entered is valid, then one day is added to it, and the new date is output to the screen The program should include: - struct Date o Declare a struct named: Date The struct has 3 data members: month, day and year (all integers) . In main(), declare an object Date and name it: today . Four functions in the program: 1.) getDate - A void-returning function, gets input from user. The object, today, is passed by reference to the function, Note: Objects of structs and classes are almost always passed by reference. The function prompts the user to enter today's date The function roads the date entered by the user. o The function returns no value. 2.) IsDateValid - Function returns a bool data type (true or false) The function is called from the getDate furicliun. The parameter for this function is the Date object that holds the month, day, and year representing the date entered by the user. This function checks to make sure the date entered is valid. NOTE Some months, like January and March have 31 days, whereas, others have 30, and February has 28 (except for leap year). This adds complexity and requires more time. Therefore, for this assignment, pretend that all months are 30 days long. o As mentioned, this function checks to make sure the date entered is valid A valid date is one where the month is greater than 0 and less than 13. (1 is January, 2 is February, etc.) . A valid date is one where the day is greater than 0 and less than 31. (Remember that all months are 30 days long in this assignment.) . A valid year is greater than 2019. Page > of 3 - ZOOM + If the date object (passed to isDateValid function) is valid, the function returns truc. . Otherwise, false is returned. of the function retums true, the getDate function is done and program execution retums to main() However, if the function returns false then a message displays: Invalid dato Still within the getDate function, the user is again prompted for today's date. Again the date is read and passed to the IsDete Valo function, and so on. Therefore, a do-while for while) loop must be included within the getDate function. . Within the loop, the user is prompted for a date, and the 1sDate Valld function is called Hint do! while (valid imput != true); 3.) addOneDay - A vold-returning function adds one day to the date entered. HINT: date.day++; it (date.day - 31) 7 date.month!!! // go to the next month date.day = 1; // first day of the next month if ( ......... // check to see if the month is 12. 1 // If yes, date.year++; // and set the month to January. 1 4.) display Tomorrow - A void-returning function displays the date after one day has been added to today's date. cout.fill('0") . This library function will fill any empty spaces with the specified character. It checks to see what setw is, and then fills if needed. Ex: cout

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

Students also viewed these Databases questions

Question

Explain the function and purpose of the Job Level Table.

Answered: 1 week ago