Programming Requirements Write a C++ program that checks whether a date entered in the form of: month day year is a valid date. Note that the format is spaced using spaces. A valid date should satisfy the following: The year should be a value between 0 and 2020 inclusive The month value between 1 and 12 inclusive The day value should: Be between 1 and 30 for the months April, June, September, and November Be between 1 and 31 for the months January, March, May, July, August, October, and December Be between 1 and 29 if the year is a leap year, and 1 and 28 if it is not. A year can be a leap year based on the following: If the year is not the end of a century (e.g., 1994), the year should be a multiple of 4. If the year is the end of a century (e.g., 2000), the year should be a multiple 400. Example execution: ranger0$ ./checkDate < checkDate.dat 6 15 1988 is valid 11 -9 1992 is not valid 1 29 1991 is valid 2 29 1982 is not valid 1 20 1997 is valid 2 29 2000 is valid 2 29 1996 is valid 2 29 1994 is not valid 6 15 2970 is not valid -4 8 1953 is not valid 4 31 1999 is not valid 6 30 2000 is valid 5 31 2015 is valid 8 31 2019 is valid 12 31 2020 is valid 12 31 2018 is valid 11 1 2001 is valid 3 15 2014 is valid

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

Objectives

  • Practice with I/O redirection
  • Practice with conditional statements in C++
  • Practice with loops in C++

Programming Requirements

Write a C++ program that checks whether a date entered in the form of:
month day year is a valid date. Note that the format is spaced using spaces. A valid date should satisfy the following:

  • The year should be a value between 0 and 2020 inclusive
  • The month value between 1 and 12 inclusive
  • The day value should:
    • Be between 1 and 30 for the months April, June, September, and November
    • Be between 1 and 31 for the months January, March, May, July, August, October, and December
    • Be between 1 and 29 if the year is a leap year, and 1 and 28 if it is not.

A year can be a leap year based on the following:

  • If the year is not the end of a century (e.g., 1994), the year should be a multiple of 4.
  • If the year is the end of a century (e.g., 2000), the year should be a multiple 400.

Example execution: ranger0$ ./checkDate &lt; checkDate.dat 6 15 1988 is valid 11 -9 1992 is not valid 1 29 1991 is valid 2 29 1982 is not valid 1 20 1997 is valid 2 29 2000 is valid 2 29 1996 is valid 2 29 1994 is not valid 6 15 2970 is not valid -4 8 1953 is not valid 4 31 1999 is not valid 6 30 2000 is valid 5 31 2015 is valid 8 31 2019 is valid 12 31 2020 is valid 12 31 2018 is valid 11 1 2001 is valid 3 15 2014 is valid

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 6 images

Blurred answer
Knowledge Booster
Concept of Parenthesis
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
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