8. Write a method 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 mm/dd/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.

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter7: Using Methods
Section: Chapter Questions
Problem 9E
icon
Related questions
Question

I need help with Java code.

I'm not sure how to start...

8. Write a method 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 mm/dd/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.
Notes: This project provides an opportunity to introduce format checking. The solution uses case
logic in combination with compound Boolean expressions.
Transcribed Image Text:8. Write a method 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 mm/dd/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. Notes: This project provides an opportunity to introduce format checking. The solution uses case logic in combination with compound Boolean expressions.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
void method
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
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,