Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In java code please and thank you in advance Write an error-free Java program to do the following things. 1. Inputs the month ( for

In java code please and thank you in advance image text in transcribed
image text in transcribed
Write an error-free Java program to do the following things. 1. Inputs the month ( for Jan, 2 for Feb, etc.), day of the month and the year from the user. The program cana user for the month/day/year in any order sk the 2. The program should inform the user when a valid date has been entered. You may assume that the user will (correctly) enter integers but the inputs may be negative, too small or too big. If an invalid date has been entered, then print a brief message explaining the problem and the program terminates gracefully. For the purposes of this assignment you may assume that February has 30 days each year, even during leap years. (I know that this does not agree with the calendar, but it will simplify some of the logic in the program.) 3. For this program assume that the minimum allowable year is 100 and the maximum allowable year is 2900. In other words, tell the user if they enter a year below 100 or above 2900 that it is an invalid date 4. If the entered date is a valid date, the program should inform the user whether the date is a leap year or not. An algorithm for determining whether a year is a leap year is shown below The algorithm for determining whether or not a year is a leap year is follows: A year that is a multiple of 400 is a leap year A year that is a multiple of 100, but not a multiple of 400 is not a leap year A year that is not a multiple of 100, but is a multiple of 4, is a leap year Sample output (2 separate computer runs): DeInput *Input day: 31 month (1 Jan, 2 Feb, etc): .ITnnut ve a r . 2002 The algorithm for determining whether or not a year is a leap year is follows A year that is a multiple of 400 is a leap year .A year that is a multiple of 100, but not a multiple of 400, is not a leap year A year that is not a multiple of 100, but is a multiple of 4 is a leap year Sample output (2 separate computer runs) .DInput day: 31 .Input month (1 Jan, 2 = Feb, etc): Input year 2002 .Day too large. Please correct. .Input day: 15 Input month (1 Jan, 2Feb, etc) 3 DInput year 2004 You have entered a correct date. .2004 is a leap year. If this program seems intimidating, then work on only one part of the program. For example, ask the user to input a month and then check if it is a valid month. Then ask for a year and check that it is greater than 100 and less than 2900. If you are feeling really overwhelmed, skip the leap year testing as it will be worth (only) 2 points out of 20 One option for programmers is to use a return; statement within main). The return statement will gracefully end the execution of the program at that point. This might be obvious but once any of the day/month/year is out of range then it is an invalid date. So the program can quit checking if it has found an invalid entry; it does not need to find all of the invalid entries if the user has made more than one

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

Introduction To Constraint Databases

Authors: Peter Revesz

1st Edition

1441931554, 978-1441931559

More Books

Students also viewed these Databases questions