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
tia_tia [17]
4 years ago
9

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

e, if givenYear is 2001 or greater (2001-2100), print "21st century".
Computers and Technology
1 answer:
irga5000 [103]4 years ago
3 0

Answer:

import java.util.Scanner;

public class num9 {

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       System.out.println("Enter year");

       int givenYear =in.nextInt();

       if(givenYear>=2101){

           System.out.println("Distant Future");

       }

       else if(givenYear>=2001){

           System.out.println("21st Century");

       }

   }

}

Explanation:

  • Using Java programming Language
  • Import Scanner class to receive user input of the variable givenYear
  • Use if statement to check the first condition if(givenYear>=2101)
  • Use else if statement to check the second condition if(givenYear>=2001)
  • print Distant future and 21st century respectively
You might be interested in
WNOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOW
beks73 [17]

Answer:

yes.

Explanation:

7 0
3 years ago
Create the logic for a game that simulates rolling two dice by generating two random numbers between 1 and 6 inclusive. The play
guajiro [1.7K]

Answer:

The solution code is written in Python 3.

  1. import random  
  2. count = 0
  3. flag = False
  4. guess = int(input("Input your guess (2-12): "))
  5. while(count <=3):
  6.    dice1 = random.randint(1, 7)
  7.    dice2 = random.randint(1, 7)
  8.    if((dice1 + dice2) == guess):
  9.        flag = True
  10.    count += 1
  11.    
  12. if(flag):
  13.    print("User wins!")
  14. else:
  15.    print("Computer wins!")

Explanation:

A Random generator is needed for this question and therefore we start by importing Python random class (Line 1)

Next, create one counter variable,<em> count</em>, to ensure there will be only three rolling of the dices (Line 3).  We need another variable, <em>flag</em>, to track the status if the two dices equal to the <em>guess</em> number chosen by user (Line 4).

Next, prompt use to input a guess number (Line 5).

Within the while loop, we can use random class method <em>randint() to </em>generate random integer. The arguments 1 and 7 will give one random number ranged from 1 to 6 for <em>dice1</em> and<em> dice2</em>, respectively (Line 8 - 9).

If the total of<em> dice1 + dice2</em> equal to user <em>guess</em>, we turn the<em> flag </em>to <em>True</em>. If not, the <em>flag </em>will remain <em>False</em> after completing entire while loop.

If the <em>flag </em>turned to <em>True</em>, print the message "User Wins!" else print the message ("Computer wins!")

8 0
4 years ago
Which letter shows the ball when it has the maximum kinetic energy
DedPeter [7]

Answer:

D.

Explanation:

Kinetic energy can be defined as an energy possessed by an object or body due to its motion.

Mathematically, kinetic energy is given by the formula;

K.E = \frac{1}{2}MV^{2}

Where;

  • K.E represents kinetic energy measured in Joules.
  • M represents mass measured in kilograms.
  • V represents velocity measured in metres per seconds square.

Generally, when the final velocity at which a physical object moves is equal to zero (0), then it possess maximum kinetic energy.

Hence, the letter which shows the ball when it has the maximum kinetic energy in the graph attached is D.

5 0
3 years ago
Write a program that echos back any inputted integer greater than 1, and exits when a 0 is entered. Your program should use a co
denpristay [2]

Answer:

MIPS Code:

.data

newline: .asciiz "\n" #newline variable

.text

MAINLOOP:

li $v0, 5 #syscall to get user interger and store in $v0

syscall

add $a0, $zero, $v0 #moving the user input to $a0 from $v0

beq $a0, 0, EXIT #branching to EXIT when $a0 is 0

li $v0, 1 #syscall to print integer in $a0

syscall

li $v0, 4 #syscall to print newline

la $a0, newline

syscall

j MAINLOOP #jumping to MAINLOOP

EXIT:

Sample Output:

6

6

7

7

3

3

0

7 0
3 years ago
if you were writing an essay about the major rivers of America which illustration would be the most helpful to your reader ​
Dmitrij [34]

Answer:A map

Explanation: (╹◡╹)

4 0
3 years ago
Other questions:
  • In which of the following stages of the development process is a team MOST likely to interview a potential user of an app?
    6·1 answer
  • The shortcut key to access the spelling and grammar check is _____.
    11·2 answers
  • You have noticed that one of your DNS servers has possibly been compromised. You believe that a cached DNS entry for your domain
    8·1 answer
  • A ________ is a gateway service that permits users to log in once, with one specific user ID and password, to gain access to mul
    8·1 answer
  • Which of the following provides services to hosts on its network?
    9·1 answer
  • Which fund classification would a focus on only stocks of technology companies match?
    10·1 answer
  • ______ view is generally used for creating, formatting and designing slide​
    13·1 answer
  • TRUE OR FALSE: COMPUTER SCIENCE!
    8·2 answers
  • Write a JavaScript program to create a multiplication table for numbers 1 to 12 using a while loop. I’ll mark brainliest, thanks
    9·1 answer
  • Question 3 of 10
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!