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 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.
This project provides an opportunity to introduce format checking. The solution uses case logic in combination with compound Boolean expressions.
See the code in CheckDate.java.
You might also like to view...
If an array contains N elements, using the selection sort, it will be sorted after, at most, __________ passes.
Fill in the blank(s) with correct word
The ability to send and receive transmissions at the same time on an Ethernet cable is referred to by what term?
A. simplex mode B. half duplex C. auto transmit D. full duplex
To join a virtual world, you usually have to agree to a set of terms and conditions called the ____________________.
Fill in the blank(s) with the appropriate word(s).
In a network operating system (NOS), ____.
A. access control policies are globally managed B. local resources are managed globally C. resources are owned by local nodes D. local operations at a node are managed by the NOS