1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
LenaWriter [7]
3 years ago
5

Write an if-else statement with multiple branches. If givenYear is 2100 or greater, print "Distant future" (without quotes). Els

e, 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. For Java
Computers and Technology
1 answer:
Elanso [62]3 years ago
5 0

Answer:

The program to this question in java can be given as

import java.util.Scanner;

//import package for take input from user.

public class Main //define class

{

public static void main(String[] args) // main function

{

Scanner input = new Scanner(System.in);

System.out.println("Enter a number:");

int givenYear=input.nextInt();

//if condition true output is "Distant future" (without quotes).

if (givenYear >= 2100)

{

System.out.print("Distant future");

}

// else if condition(2000-2099) true output is "21st century".

else if((givenYear >= 2000) && (givenYear <= 2099))

{

System.out.print( "21st century");

}

//else if condition (1900-1999) true output is "20th century".

else if((givenYear >= 1900) && (givenYear <= 1999)){

System.out.print( "20st century");

}

//else condition false output is "Long ago".

else{

System.out.print( "Long ago");

}

}

}

Explanation:

In this program we use the scanner class. Scanner class is used to take input from the user.When the user input the input the year. It hold on a variable(givenYear) that is integer type.Then we check the value between the ranges that is given in question.To check all the condition we use the if-elseif-else statement, and AND(&&) operator.AND operator is a logical operator that is used for compare two values together. The output of the program can be given as:

Output:

Enter a number: 2016

21st century

You might be interested in
What is the answer to in Microsoft Word you can access the blank from the command command from the mini toolbar what is the corr
fgiga [73]
<span>The correct answer is: Option (C) Underlined

Explanation:
In Microsoft Word (version 2007 and version 2010), the following commands you can use:
1. Bold
2. Highlight Text
3. Font Size
4. Italics
5. Underline
6. Format Painter
7. Increase indent of text
8. Decrease indent of text
9. Increase font size
10. Center text (alignment)

Word count, save as and insert citation commands do not exist in the mini-toolbar. Hence, the correct option is Option (C) Underlined</span>
4 0
3 years ago
Read 2 more answers
Which two functions can be used with the math module?
GrogVix [38]

Answer: The math module presents two angle conversion functions: degrees() and radians() , to convert the angle from degrees to radians and vice versa. For example, the following statements convert the angle of 30 degrees to radians and back (Note: π radians is equivalent to 180 degrees).

Explanation: Hopefully this helps you. It is a full answer.

5 0
3 years ago
Write a recursive method called repeat that accepts a string s and an integer n as parameters and that returns s concatenated to
svp [43]

Answer:

public static String repeat(String text, int repeatCount) {

   if(repeatCount < 0) {

       throw new IllegalArgumentException("repeat count should be either 0 or a positive value");

   }

   if(repeatCount == 0) {

       return "";

   } else {

       return text + repeat(text, repeatCount-1);

   }

}

Explanation:

Here repeatCount is an int value.

at first we will check if repeatCount is non negative number and if it is code will throw exception.

If the value is 0 then we will return ""

If the value is >0 then recursive function is called again untill the repeatCount value is 0.

6 0
3 years ago
WILL GIVE BRAINLIEST! An ________________ is a list of steps needed to answer a problem or finish a task. When the code is execu
Fudgin [204]

Answer:

Event

Explanation:

8 0
3 years ago
Read 2 more answers
What is the Rocker-Bogie System?
Dovator [93]

Answer:

The Rocker-Bogie System is the suspension arrangement developed in 1988 for use in NASA's Mars Rover Sojourner and which has become NASA's favored design for rovers.

Hope that this helps!

4 0
3 years ago
Other questions:
  • "Suppose there is a class Alarm. Alarm has two class variables, code which contains a String value representing the code that de
    10·1 answer
  • What is the preferred procedure for putting customers on hold​
    14·2 answers
  • Who played a leading role in perfecting movable type for printing?
    15·1 answer
  • What hernia repair codes can be reported with add-on code 49568?
    6·1 answer
  • Josh wants to sign up for a gaming website. It will allow him to download games. He can’t find a privacy policy. Should he join
    9·2 answers
  • Which type of operating system is usually used in personal computers
    13·1 answer
  • Write a function that parses a binary number into a hex number. The function header is:def binaryToHex(binaryValue)Write a test
    11·1 answer
  • A customer has a computer for a home business, but wants to have another computer as a web server. What would be the best soluti
    11·2 answers
  • What one main difference between social media and traditional media such as television?
    12·2 answers
  • Write a program in c# that simulates the roll of two six sided dice.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!