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
which of the following conditions will maximize the amount of interest you earn A: ahigh interest rate &amp;long time period B:
Neko [114]
A The longer you wait the higher your interest gets <span />
4 0
3 years ago
Fromwhich object do you ask for DatabaseMetaData?ConnectionResultSetDriverManagerDriver
icang [17]

Answer:

Connection

Explanation:

We can get DatabaseMetaData from the java.sql.Connection object.

The relevant API call is Connection.getMetaData().

This returns an object of the type DatabaseMetaData.

Some of the methods available as part of the DatabaseMetaData object are:

  • getDatabaseMajorVersion()
  • getDatabaseMinorVersion()
  • getDriverName()
  • getDriverVersion()
  • isReadOnly()
  • getCatalogs()
  • getTables()
  • supportsBatchUpdate()
  • supportsUnion()
8 0
3 years ago
________ can be written only once. The data cannot be erased or written over once it is saved.​
notka56 [123]

Answer:

WORM (Write Once, Read Many)

Explanation:

The full meaning which means Write Once, Read Many implies that data can only be entered (or better put, written) once. Once the data has been written, the data can not be updated or deleted. However, the data being stored on WORM can be read as many times, as possible.

Hence, WORM answers the question.

6 0
3 years ago
Consider two different implementations, M1 and M2, of the same instruction set. There are three classes of instructions (A, B, a
Margaret [11]

Explanation:

A.)

we have two machines M1 and M2

cpi stands for clocks per instruction.

to get cpi for machine 1:

= we multiply frequencies with their corresponding M1 cycles and add everything up

50/100 x 1 = 0.5

20/100 x 2 = 0.4

30/100 x 3 = 0.9

CPI for M1 = 0.5 + 0.4 + 0.9 = 1.8

We find CPI for machine 2

we use the same formula we used for 1 above

50/100 x 2 = 1

20/100 x 3 = 0.6

30/100 x 4 = 1.2

CPI for m2 =  1 + 0.6 + 1.2 = 2.8

B.)

CPU execution time for m1 and m2

this is calculated by using the formula;

I * CPI/clock cycle time

execution time for A:

= I * 1.8/60X10⁶

= I x 30 nsec

execution time b:

I x 2.8/80x10⁶

= I x 35 nsec

6 0
3 years ago
Top-level domain names are sometimes called _____.
Xelga [282]
Internet domain extention 
4 0
3 years ago
Other questions:
  • Is printer an input device​
    5·1 answer
  • Bill needs to make a presentation in which he has to represent data in the form of a pyramid. Which feature or menu option of a
    10·2 answers
  • In GIMP, the ( ) displays the image that the user is currently working on
    12·1 answer
  • Need 2.5 Code Practice Answers
    14·2 answers
  • In the receiving computer, UDP receives a datagram from the __________ layer.
    15·1 answer
  • Jasmine is writing a shopping app. She has created a variable to keep track of the number of items in the shopping cart. Everyti
    11·1 answer
  • 90 points can someone please write the code for this (HTML):
    13·1 answer
  • 2. The internet offers a great source of information; however, how are
    9·1 answer
  • Downlad the file and write a program named Lab10b_Act2.py that does the following: Opens the CSV file for reading Reads the CSV
    15·1 answer
  • Which of the following statements are true regarding models? Select 3 options.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!