Computers and Technology
Computers and Technology, 21.03.2020 05:34, peno211

Writing a Modular Program in C++

In this lab, you add the input and output statements to a partially completed C++ program. When completed, the user should be able to enter a year, a month, and a day. The program then determines if the date is valid. Valid years are those that are greater than 0, valid months include the values 1 through 12, and valid days include the values 1 through 31.

Notice that variables have been declared for you.

Write the simulated housekeeping() function that contains the prompts and input statements to retrieve a year, a month, and a day from the user.

Include the output statements in the simulated endOfJob() function. The format of the output is as follows:

month/day/year is a valid date.

or

month/day/year is an invalid date.

Execute the program entering the following date: month = 5, day = 32, year = 2014. Record the output of this program.

Execute the program entering the following date: month = 9, day = 21, year = 2002. Record the output of this program.



/* Program Name: BadDate. cpp
Function: This program determines if a date entered by the user is valid.
Input: Interactive
Output: Valid date is printed or user is alerted that an invalid date was entered
*/

#include
bool validateDate(int, int, int);
using namespace std;
int main()
{
// Declare variables

int year;
int month;
int day;
const int MIN_YEAR = 0, MIN_MONTH = 1, MAX_MONTH = 12, MIN_DAY = 1, MAX_DAY = 31;
bool validDate = true;

// This is the work of the housekeeping() method
// Get the year, then the month, then the day
cout<<"Enter the year"< cin>>year;
cout<<"Enter the month"< cin>>month;
cout<<"Enter the day"< cin>>day;

// This is the work of the detailLoop() method
// Check to be sure date is valid

if(year <= MIN_YEAR) // invalid year
validDate = false;
else if (month < MIN_MONTH || month > MAX_MONTH) // invalid month
validDate = false;
else if (day < MIN_DAY || day > MAX_DAY) // invalid day
validDate = false;

// This is the work of the endOfJob() method
// test to see if date is valid and output date and whether it is valid or not
if(validDate == true);
{
// Output statement

cout< }
else
{
// Output statement
cout<
}

} // end of main() function

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 04:00, AngiT
Which spereadsheet type will determine how well a bussiness has done over the past year
Answers: 1
image
Computers and Technology, 23.06.2019 10:00, thezbell
What is estimated time of arrival (eta)? a device that measures the acceleration (the rate of change of velocity) of an item and is used to track truck speeds or taxi cab speeds a gps technology adventure game that posts the longitude and latitude location for an item on the internet for users to find a north/south measurement of position the time of day of an expected arrival at a certain destination and is typically used for navigation applications
Answers: 3
image
Computers and Technology, 24.06.2019 06:50, emmv565628
What are the things you are considering before uploading photos on social media?
Answers: 1
image
Computers and Technology, 25.06.2019 05:30, salllllllllll
In our new car, we were able to drive 30 miles in a half an hour. from this information, we can determine the car's a. acceleration. b. velocity. c. speed. d. direction.
Answers: 1
Do you know the correct answer?
Writing a Modular Program in C++

In this lab, you add the input and output statements t...

Questions in other subjects:

Konu
Mathematics, 11.09.2020 14:01
Konu
Mathematics, 11.09.2020 14:01
Konu
Mathematics, 11.09.2020 14:01
Konu
Mathematics, 11.09.2020 14:01
Konu
Mathematics, 11.09.2020 14:01
Konu
Mathematics, 11.09.2020 14:01
Konu
Mathematics, 11.09.2020 14:01
Konu
Mathematics, 11.09.2020 14:01
Konu
Spanish, 11.09.2020 14:01
Konu
Mathematics, 11.09.2020 14:01