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
Ket [755]
3 years ago
10

Write an expression that executes the loop body as long as the user enters a non-negative number. Note: If the submitted code ha

s an infinite loop, the system will stop running the code after a few seconds and report "Program end never reached." The system doesn't print the test case that caused the reported message. Sample outputs with inputs: 9 5 2 -1 Body Body Body Done.
Computers and Technology
1 answer:
Mama L [17]3 years ago
8 0

In the program While loop is used. In the while loop it divides the userNum by 2 in each iteration and prints the value of userNum. The inputs and corresponding outputs are written in the explanation.

<u>Explanation</u>:

In the while loop it divides the userNum by 2 in each iteration and prints the value of userNum.

import java.util.Scanner;  

public class NonNegativeLooper

public static void main (String [] args)

Scanner scnr = new Scanner(System.in);  

//initialize the userNum with 9

int userNum = 9;

//Repeat the loop until the userNum is not negative

while (userNum>=0)

System.out.println(Body);

//Prompt the user to enter the usrNum again

userNum = scnr.nextInt();

System.out.println(Done.);

return;

You might be interested in
Which sequence represents the hierarchy of terms, from smallest to greatest?
Anni [7]

Answer:

b

Explanation:

7 0
2 years ago
Free point giveaway pt.10 and brainliest to first answer
g100num [7]

Answer:

3+3=6

Explanation:

Tysm!!!

8 0
3 years ago
Read 2 more answers
When a number gets assigned to a variable that already has a value __________?
Aleksandr-060686 [28]
A already assigned variable cannot be assigned twice You can make the variable change over to a new one or call a whole new one to assign one without a value or It might be possible to do v=n (v is variable and n is number / value)
3 0
3 years ago
Computers infected by a virus, worm, or Trojan horse that allows them to be remotely controlled for malicious purposes are calle
yuradex [85]

Blaster Worm., the worm has been designed to tunnel into your system and allow malicious users to control your computer remotely. A Trojan horse is not a virus. It is a destructive program that looks as a genuine application. Unlike viruses, Trojan horses do not replicate themselves but they can be just as destructive.

4 0
2 years ago
Create a class called Fraction. Provide a constructor that takes 2 integers. Provide methods for:
tekilochka [14]

Answer:

Explanation;

else

System.out.println("f1 and f2 are not equal");

switch (input.charAt(0)

{

case '+':

f3 = f1.add(f2);

System.out.println("f1+f2=" + f3);

break;

case '-':

f3 = f1.subtract(f2);

System.out.println("f1-f2=" + f3);

break;

case '*':

f3 = f1.multiply(f2);

System.out.println("f1*f2="+f3);

break;

case '/':

f3 = f1.divide(f2);

System.out.println("f1/f2="+f3);

break;

default:

System.out.println("Illegal command: " + input );

break;

}

}// end of while loop

} // end of main

}

 

Note ; this is the last part of the programme check the attachment from 1-5  this is the 6th .

8 0
3 years ago
Other questions:
  • Does toontown rewritten carry spyware or malware
    9·1 answer
  • Open source software is copyrighted software that is distributed at no cost for a trial period.
    11·1 answer
  • How to tell if motherboard has bluetooth?
    8·1 answer
  • What are some of the ways you can use bitlocker encryption? (choose all that apply?
    10·1 answer
  • If you wish to maintain a consistent style to all the documents you create, it would be helpful to use a _​
    5·1 answer
  • To drive defensively means taking proactive measures to avoid accident situations regardless of their potential causes.
    6·2 answers
  • A new drug to combat acne has been developed from a compound that is found in a melon. Which scientists would contribute to the
    15·2 answers
  • What do you find when you first open a word processor and how do you adjust the document Indentitions
    6·1 answer
  • Giving 5 stars, a Thanks, 80 points, and Branliest to whoever answers them correctly.
    9·1 answer
  • 2. Explain the difference between a JMP instruction and CALL instruction
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!