Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a Java application program that will allow the user to enter a date. The program will then check the date to verify whether or

image text in transcribed
Write a Java application program that will allow the user to enter a date. The program will then check the date to verify whether or not it is a valid date. Begin by asking the user to enter a date in the form, mm/dd/yyyy. This will be entered as a String since the date contains slash marks. After the date is entered, the program should check the datelfor validity. If the date is valid, the program should display the message "Valid date". If the date is not valid, the program should display the message "Not a valid date" along with a message to indicate why the date is not valid. To check the date: Begin by checking to make sure the user has entered enough characters. A correct date should consist of exactly 10 characters . no more and no less. lf the user has not entered the correct number of characters, display whichever of the following messages is appropriate: Too few characters in the date Too many characters in the date If the first test turned out to be ok, next you should check to make sure that the slash marks are n the correct positions. In a correctly entered date, a slash mark should be the third character in the string, and also the sixth character in the string. If you do not find slash marks at these two points, display the following message: Incorrect format If the first two tests turned out to be ok, next you should check the month. You will need to extract the month part from the string. Since it will be extracted as a string, you will then need to convert it to an integer so you can check it's value. A valid month value must be from 1 to 12. If the month is not in the proper range, display the following message: Month is not valid . If the first three tests turmed out to be ok, next check the day. You will need to extract the day part from the string. Since it will be extracted as a string, you will then need to convert it to an integer so you can check it's value. The day value should not be less than 1 It should also not be greater than 28, 29, 30 or 31; whichever 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. If the day is not in the proper range, display the following message: Day is not valid The following is an example of what your MIGHT see on the screen when your program runs. The exact output depends on what values that the user types in while the program runs. The users inputted values are shown below in italics

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Database Factory Active Database For Enterprise Computing

Authors: Schur, Stephen

1st Edition

0471558443, 9780471558446

Students also viewed these Databases questions

Question

Do you believe firms should be allowed to engage in tax inversions?

Answered: 1 week ago