Answered step by step
Verified Expert Solution
Question
1 Approved Answer
You are tasked with creating a program that will take a calender year (ex. 2001) and determine the following two: 1) The century (ex.
You are tasked with creating a program that will take a calender year (ex. 2001) and determine the following two: 1) The century (ex. 2000 is the 20th century and 2001 is the 21st century) a) To determine the century you divide the year by 100 (century), use Math.trunc (), and apply the one of the following: Ex: var x = Math.trunc (12/3); 1.a) Add 1, if the year does not end in 00 (look into modulus (8) operator) 1.b) Display the century as it is. 2) If it is a leap year or not a leap year a) A year will be a leap year if it is divisible by 4 but not by 100. If a year is divisible by 4 and by 100, it is not a leap year unless it is also divisible by 400. (Note: Nested conditions and look into modulus (8) operator) Notes: - You should ask for the user to enter a year using the message Enter a year after 1582: If the year entered is before 1582, display the message n is before 1582, where n is the year the user input If the year entered is after 1582 and it is a leap year, you must display the message n is a leap year, where n is the year the user input or if the year is not a leap year, then the message n is not a leap year, where n is the year the user input */ Sample runs to try this runs Enter a year after 1582: 12 12 is before 1582. Enter a year after 1582: 2000 century is: 20 2000 is a leap year. Enter a year after 1582: 2001 century is: 21 2001 is not a leap year. */ // Write your program below here
Step by Step Solution
★★★★★
3.31 Rating (163 Votes )
There are 3 Steps involved in it
Step: 1
import JavautilScanner CenturyLeapYear community category public static void main String args Sca...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