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]
4 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]4 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
Using the Invert Selection tool while something is selected in Paint will __________.
valentinak56 [21]
Change the selection to include everything on the picture except what was originally selected.

This is because inversion is basically flipping everything you did inside out.

Hope this helps!
3 0
3 years ago
Sean Cody is a website most known for what?
sergejj [24]

Answer:

Sean Cody is a website most known for to translate English to Portuguese.

8 0
3 years ago
Read 2 more answers
Emily is deciding whether to buy the same designer jacket her friends have. The jacket is much more expensive than a similar one
Galina-37 [17]
Is advertising influencing her?
What are her motivations?
Has she compared prices?
Is she buying at the right time?
5 0
3 years ago
Read 2 more answers
What is the next line?
lianna [129]

Answer:

4

Explanation:got it right on edg.

4 0
3 years ago
Write a program to solve the selection problem. Let k = N/2. Draw a table showing the running time of your program for various v
Brums [2.3K]
So here is the code in Python:

n = 0.00 #this is a float because there are some numbers that are decimals.

while n < 20: #n which is 0.00 and while it is lower than 20 if runs the code below
n = n + 1 #it will add 1 to n everything it runs the code.
k = n / 2 #it will divide whatever n is everytime by 2
print(str(n) + '/2: ') # it's printing the number it's on
print(k) # prints the answer for the n.

You can change n to add by any, make n any num instead of 0.00 and you can change the while condition from n < 20 to any other logical statement. If you want to get creative you can take 2 inputs for numbers and make one of them the starting number and other one is the ending number. Also make sure to make n a number lower than you starting point because if you set n as your starting point then it will skip it.

4 0
3 years ago
Other questions:
  • Technician A says that in any circuit, electrical current takes the path of least resistance. Technician B says that while this
    11·2 answers
  • Which data type is most suitable for a password field
    12·1 answer
  • You can access a button s screentip by _____.
    6·1 answer
  • No matter what medium connects computers on network-copper wires, fiber-optic cables, or a wireless setup; the same protocol mus
    11·1 answer
  • In "When Is a Planet Not a Planet?" why does the author say that the outer planets are made of gas when the inner planets are ma
    5·1 answer
  • Write a Python program segment, using a loop, to calculate and print the sum of the odd integers from 20 to 120. (Hint: 21 23 25
    13·1 answer
  • Hey guys, I don’t have a problem for you but If anyone knows do you still pass your grade level if you failed 1 class in the las
    11·2 answers
  • Select the correct answer.<br> What do you understand by "exposition"?
    10·2 answers
  • What is a computer please tell me ​
    10·2 answers
  • How to connect two routers wirelessly to extend range.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!