subject
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

ansver
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 22:40, shaylawaldo11
Write a program that defines symbolic names for several string literals (chars between quotes). * use each symbolic name in a variable definition. * use of symbolic to compose the assembly code instruction set can perform vara = (vara - varb) + (varc - vard); ensure that variable is in unsigned integer data type. * you should also further enhance your symbolic logic block to to perform expression by introducing addition substitution rule. vara = (vara+varb) - (varc+vard). required: debug the disassembly code and note down the address and memory information.
Answers: 3
image
Computers and Technology, 23.06.2019 18:30, bsept1018
Report all segments of identity by descent longer than 20 polymorphisms between pairs of individuals in the following cohort of 15 individuals across 49 polymorphisms: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 numeric input 2 points possible (graded) you have 2 attempts to complete the assignment below. for example if the sequence is "bcd", which occurs in "abcdef" , the starting point would be 2 (b), and the finishing point would be 4(d). individuals 7,10 between positions
Answers: 1
image
Computers and Technology, 24.06.2019 07:00, Dkhaurithompson
Selective is defined as paying attention to messages that are consistent with one’s attitudes and beliefs and ignoring messages that are inconsistent.
Answers: 1
image
Computers and Technology, 24.06.2019 22:30, gabi83
To add additional commands to the quick access toolbar, a user can navigate to the view. backstage status bar design file
Answers: 2
You know the right 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.11.2020 19:00
Konu
Mathematics, 11.11.2020 19:00
Konu
English, 11.11.2020 19:00
Konu
Mathematics, 11.11.2020 19:00