Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 02: A date in the form dd mm yyyy can be converted to a decimal form yyyy.xxxxx where the decimal part.xxxxx is calculated as

image text in transcribed

Question 02: A date in the form dd mm yyyy can be converted to a decimal form yyyy.xxxxx where the decimal part.xxxxx is calculated as (NumberOfDaysFromFirstlanuaryOfTheYear ToTheDate-1)/ NumberofDaysForTheYear Where NumberOfDaysForTheYear is 365.0 for a non-leap year, and 366.0 for a leap year Examples: 1 1 2018 s 2018(1-1)/365.0 2018.000000 3 2 2017 2017+ (34-1)/365.0 2017.0904109 5 3 2020 s 2020 (65-1)/366.02020.17486338 Note: 2020 is a leap year] Write an interactive Java program to compute and display the decimal form of a date for a date that is input at the keyboard in the form dd mm yyyy Your program must check for input validity. It must display an appropriate error message and loop as long as the three inputs for date (day, month, and year) do not form a valid date. Your program must also recover from InputMismatchException. In addition to the main method your program must use the following private static methods: A void method that displays the following message to the user: boolean method that tests for input validity. The method returns true if the three inputs form a valid date A boolean method that returns true if its parameter year is a leap year; otherwise it returns false (A leap year . month year." "This program computes and displays the decimal form of a date input as: day otherwise it returns false. This function must not have calls to input or output methods. is a year that has 366 days). This method must not have calls to input or output methods. An int method that returns the number of days from 1st January to the date. This method must not have calls to input or output methods A method of type double that returns the decimal form of a date. This method must not have calls to input or output methods. . Note . A year is a leap year if it is divisible by 400; otherwise if it is divisible by 4 and not divisible by 100 . Assume a year is between 1900 and 3000 inclusive, ie., 1900 year 3000 . Your program must be general YOUR PROGRAM MUST NOT USE Java Date, Time, or Calendar APIs. . Your program must behave as the sample program runs below Sample program runs: This program computes and displays the decimal date of a date input a day month year Enter day, month, and year: dfg Error: java.util.InputMismatchException Enter day, month, and year: 9 9 4000 Error: The date is not valid Enter day, month, and year: 1 1 2018 The decimal date is: 2018.000000

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

Oracle 12c SQL

Authors: Joan Casteel

3rd edition

1305251032, 978-1305251038

More Books

Students also viewed these Databases questions

Question

=+ What topics are contained in the contracts?

Answered: 1 week ago

Question

=+Are they specific or general in nature?

Answered: 1 week ago