Question: In JAVA Write an if-else statement with multiple branches. If givenYear is 2100 or greater, print Distant future (without quotes). Else, if givenYear is 2000
In JAVA
Write an if-else statement with multiple branches. If givenYear is 2100 or greater, print "Distant future" (without quotes). Else, if givenYear is 2000 or greater (2000-2099), print "21st century". Else, if givenYear is 1900 or greater (1900-1999), print "20th century". Else (1899 or earlier), print "Long ago". Do NOT end with newline.
With the following code:
import java.util.Scanner;
public class YearChecker { public static void main (String [] args) { int givenYear = 0;
givenYear = 1776;
/* Your solution goes here */
return; } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
