Decisions, decisions, decisions. Computers are terrible at them, so as programmers we need to instruct them on how to make good ones. In this lab you will write a program that accepts a date in the form “month/day/year” and prints whether or not the date is valid. For example 5/24/1962 is valid, but 9/31/2000 is not. (September has only 30 days.) Your program, in order to be correct, should be able to pass these simple (but far from complete!) test cases: 2/29/2000 — (valid) 2/29/2001 — (not valid) 4/30/1984 — (valid) 4/31/1984 — (not valid) 0/12/1234 — (not valid) 13/30/2014 — (not valid) 10/24/2014 — (valid) I’m OK with you allowing leading zeros for the month, or day. This is optional, however. 03/04/2017 — (valid) 07/22/2019 — (valid) 00/12/1234 — (not valid) Generally speaking, I want to see the following structure in your program. This encourages “separation of concerns”: Obviously, you will be using if-elif-else statements to make decisions in your program. The function main() should print a friendly message and ask for the input of the date in the required format (see above). It then should parse the date into its day, month and year components. It will pass this information to a “date check” function. A “date check” function named is_valid_date(day, month, year) that will take these date components of day, month and year and checks to see if that date is valid. The function parameters day, month, and year must be integer values. This function is required to return a Python True or False boolean value (reflecting a valid, or invalid date, respectively) that your main() function will use to print out the correct message about the date’s validity. A function named is_leap_year(year) that calculates leap year needs to be used by your date check function. This formula should be easy to look up. The function parameters year must be an integer value. You need to write this function that takes takes a year as a parameter that will then return a Python True or False boolean value (reflecting a leap, or non-leap year, respectively)

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter5: Control Structures Ii (repetition)
Section: Chapter Questions
Problem 19PE
icon
Related questions
Question

Decisions, decisions, decisions. Computers are terrible at them, so as programmers we need to instruct them on how to make good ones. In this lab you will write a program that accepts a date in the form “month/day/year” and prints whether or not the date is valid. For example 5/24/1962 is valid, but 9/31/2000 is not. (September has only 30 days.)

Your program, in order to be correct, should be able to pass these simple (but far from complete!) test cases:

  • 2/29/2000 — (valid)

  • 2/29/2001 — (not valid)

  • 4/30/1984 — (valid)

  • 4/31/1984 — (not valid)

  • 0/12/1234 — (not valid)

  • 13/30/2014 — (not valid)

  • 10/24/2014 — (valid)

I’m OK with you allowing leading zeros for the month, or day. This is optional, however.

  • 03/04/2017 — (valid)

  • 07/22/2019 — (valid)

  • 00/12/1234 — (not valid)

Generally speaking, I want to see the following structure in your program. This encourages “separation of concerns”:

  1. Obviously, you will be using if-elif-else statements to make

    decisions in your program.

  2. The function main() should print a friendly message and ask for the input of the date in the required format (see above). It then should parse the date into its day, month and year components. It will pass this information to a “date check” function.

  3. A “date check” function named is_valid_date(day, month, year) that will take these date components of day, month and year and checks to see if that date is valid.

    • The function parameters day, month, and year must be integer values.

    • This function is required to return a Python True or False boolean value (reflecting a valid, or invalid date, respectively) that your main() function will use to print out the correct message about the date’s validity.

  4. A function named is_leap_year(year) that calculates leap year needs to be used by your date check function. This formula should be easy to look up.

    • The function parameters year must be an integer value.

    • You need to write this function that takes takes a year as a parameter that will then return a Python True or False boolean value (reflecting a leap, or non-leap year, respectively).

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Constants and Variables
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
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning