/* 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            // 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         }   else   {      // Output statement         }       } // end of main() function

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
/* 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 <iostream>
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
     
  

  // 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
     
  }
  else
  {
     // Output statement
     
  }
     
} // end of main() function
Writing a Modular Program in C++
BadDa
1/* F
pols
Instructions
3
4
1. Notice that variables have been declared for you.
5*/
5/3
2. Write the simulated housekeeping() function
7 #inc
that contains the prompts and input statements
8 bool
9 usin
to retrieve a year, a month, and a day from the
10 int
user.
11 {
12
//
3. Include the output statements in the simulated
13
endof Job() function. The format of the output is
14
in
15
in
as follows:
16
in
17
Co
18
boc
month/day/year is a valid date.
19
//
//
20
21
or
22,
23
24
month/day/year is an invalid date.
25
26
//
27
4. Execute the program by clicking the Run button
281
at the bottom of the screen. Enter the following
29
if(
date:
30
31
else
32
nonth = 5, day = 32, year = 2014.
3
lelse
34
35
5. Execute the program entering the following date:
36
// T
137
38
if(v
39
month = 9, day = 21, year = 2002.
40
4.
立
in
日 !
Transcribed Image Text:Writing a Modular Program in C++ BadDa 1/* F pols Instructions 3 4 1. Notice that variables have been declared for you. 5*/ 5/3 2. Write the simulated housekeeping() function 7 #inc that contains the prompts and input statements 8 bool 9 usin to retrieve a year, a month, and a day from the 10 int user. 11 { 12 // 3. Include the output statements in the simulated 13 endof Job() function. The format of the output is 14 in 15 in as follows: 16 in 17 Co 18 boc month/day/year is a valid date. 19 // // 20 21 or 22, 23 24 month/day/year is an invalid date. 25 26 // 27 4. Execute the program by clicking the Run button 281 at the bottom of the screen. Enter the following 29 if( date: 30 31 else 32 nonth = 5, day = 32, year = 2014. 3 lelse 34 35 5. Execute the program entering the following date: 36 // T 137 38 if(v 39 month = 9, day = 21, year = 2002. 40 4. 立 in 日 !
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Types of Function
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education