Question
(JAVA)Use a variable to accept and store user input. This variable will be a number representing the month. Ex. Jan = 1, Feb =2, Mar
(JAVA)Use a variable to accept and store user input. This variable will be a number representing the month. Ex. Jan = 1, Feb =2, Mar =3, Your code will figure out and display the name of the, the number of days in that month and for Feb ask the user to input the year and display a message whether it is a leap year or not how many days, hours, min and sec as shown in the sample output below.
i. Extra credit: figure out the best way to accept user input to help you determine whether this is a leap year or not. Based on the result, display February as 28 or 29 days with its corresponding number of seconds.
ii. Extra credit: Odd numbered months have 31 days until you get to July, then starting with August even numbered months have 31 days. How can you make your code more efficient as not having to write 12 if conditions?
Hint: A leap year is any year divisible by four except those years divisible by 100 unless the year is also divisible by 400. You could modify your code to accept user input for the year and use the expression in the book to determine leap year.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started