/* 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
/* 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
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
日 !](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F4bfbb203-4399-4804-a6b8-bbfebafe4401%2F26b39dd1-610c-40b2-98ab-3c2722748a37%2Fntjqful_processed.jpeg&w=3840&q=75)
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
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Knowledge Booster
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.Recommended textbooks for you
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
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)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
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)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education