Q3) Write a program that reads a string from the keyboard and tests whether it contains a valid date. Display the date and a message that indicates whether it is valid. If it is not valid, also display a message explaining why it is not valid. The input date will have the format dd/mm/yyyy. A valid month value mm must be from 1 to 12 (January is 1). The day value dd must be from 1 to a value that is appropriate for the given month. September, April, June, and November each have 30 days. February has 28 days except for leap years when it has 29. The remaining months all have 31 days each. A leap year is any year that is divisible by 4 but not divisible by 100 unless it is also divisible by 400. Sample Input#1: Please enter a date to be checked: 05/04/2021 Sample Output#1: Your date was 05:04:2021 It is a valid date. Sample Input #2: Please enter a date to be checked: 32/03/2021 Sample Output #2: Your date was 32:03:2021 It isn’t a valid date.The reason it is invalid:The day value is greater than 31 in a month with just 31 days. Sample Input #3: Please enter a date to be checked: 30/02/2020 Sample Output #3: Your date was 30:02:2020. It isn’t a valid date.The reason it is invalid:The day value is greater than 29 in February in a leap year. Sample Input #4: Please enter a date to be checked: 29/02/2019 Sample Output #4: Your date was 29:02:2019. It isn’t a valid date.The reason it is invalid:The day value is greater than 28 in February in a non- leap year. Note: you should upload a java project file, otherwise will not be accepted.

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
icon
Concept explainers
Question
Q3) Write a program that reads a string from the keyboard and tests whether it contains a valid date. Display the date and a message that indicates whether it is valid. If it is not valid, also display a message explaining why it is not valid. The input date will have the format dd/mm/yyyy. A valid month value mm must be from 1 to 12 (January is 1). The day value dd must be from 1 to a value that is appropriate for the given month. September, April, June, and November each have 30 days. February has 28 days except for leap years when it has 29. The remaining months all have 31 days each. A leap year is any year that is divisible by 4 but not divisible by 100 unless it is also divisible by 400. Sample Input#1: Please enter a date to be checked: 05/04/2021 Sample Output#1: Your date was 05:04:2021 It is a valid date. Sample Input #2: Please enter a date to be checked: 32/03/2021 Sample Output #2: Your date was 32:03:2021 It isn’t a valid date.The reason it is invalid:The day value is greater than 31 in a month with just 31 days. Sample Input #3: Please enter a date to be checked: 30/02/2020 Sample Output #3: Your date was 30:02:2020. It isn’t a valid date.The reason it is invalid:The day value is greater than 29 in February in a leap year. Sample Input #4: Please enter a date to be checked: 29/02/2019 Sample Output #4: Your date was 29:02:2019. It isn’t a valid date.The reason it is invalid:The day value is greater than 28 in February in a non- leap year. Note: you should upload a java project file, otherwise will not be accepted.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 3 images

Blurred answer
Knowledge Booster
Control Structure
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