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
kakasveta [241]
4 years ago
15

Consider the following code segment. int count = 1; int value = 31; while (value >= 10) { value = value - count; count = coun

t + 3; } System.out.println(value); What is printed as a result of executing the code segment?
Computers and Technology
1 answer:
Scrat [10]4 years ago
7 0

Answer:

30

26

19

9

Explanation:

Initially, the value of count is 1 and the value of the variable “value” is 31. Since value is greater than 10, the while loop condition holds true and the program enters the while loop and will continue to execute the code inside the loop until the value changes to less than 10. “value” is reduced in the statement “value = value – count;”. Since we know value is initially 31, and count is 1, the value after this statement is executed will become value=31-1 = 30. “count” variable is now incremented by 3, so it now becomes 1+3 = 4. The next line will print this value onto the screen. The loop run again since value is >= 10. In the second run, the value will decrement by 4 as count was incremented by 3 in the previous run. Therefore, the value would become 26, while the count is again incremented by 3 to its new value 7. In the next run, the value of the value variable is therefore decremented by 7 to its new value 19 (26-7=9), and count is again incremented by 3 to make it 10 (7+3=10). The value is decremented by 10 to its new value 9 in the next run. Since 9 is less than 10 the while condition is no longer true and the program exits the while loop.

You might be interested in
Nina is trying to learn more about how computers work. She has repeatedly read that the motherboard is the "brain” of the comput
Lady bird [3.3K]

Its

Processes the data on the computer .

5 0
3 years ago
Read 2 more answers
What shoul i get, Airpods or a ps4 cooling fan ???
Fynjy0 [20]

Answer:

Airpods, there is ps5 coming out

Explanation:

3 0
3 years ago
Read 2 more answers
One of the jobs of the webmaster are to create a website<br>true or false
Talja [164]

true is the correct answer

8 0
3 years ago
Read 2 more answers
Write an if/else statement that compares the double variable pH with 7.0 and makes the following assignments to the int variable
levacccp [35]

Answer:

if (pH<7.0){

          neutral=0;

          base=0;

          acid=1;

      }

      else if (pH>7.0){

          neutral=0;

          base=1;

          acid=0;

      }

      else if (pH==7.0){

          neutral=1;

          base=0;

          acid=0;

      }

Explanation:

As required by the question, if and else statements have been used to test the value of the pH and assign the apropriate values to the variables neutral, base and acid.

The code snippet below can be used to prompt the user to enter values for pH

<em>import java.util.Scanner;</em>

<em>public class pHTest {</em>

<em>   public static void main(String[] args) {</em>

<em>      Scanner scr = new Scanner(System.in);</em>

<em>       System.out.println("Enter a value for the pH");</em>

<em>       int neutral, base, acid;</em>

<em>       double pH = scr.nextDouble();</em>

<em> if (pH<7.0){</em>

<em>           neutral=0;</em>

<em>           base=0;</em>

<em>           acid=1;</em>

<em>       }</em>

<em>       else if (pH>7.0){</em>

<em>           neutral=0;</em>

<em>           base=1;</em>

<em>           acid=0;</em>

<em>       }</em>

<em>       else if (pH==7.0){</em>

<em>           neutral=1;</em>

<em>           base=0;</em>

<em>           acid=0;</em>

<em>       }</em>

<em>} }</em>

4 0
4 years ago
Read 2 more answers
Instant messaging allows text only <br> a. True <br> b. False
xenn [34]
False!                           

There are other things you can do like send pictures and etc.
6 0
4 years ago
Other questions:
  • A set of communication rules for the computer to follow is called, what?
    10·2 answers
  • ________ are the most popular method used by visitors to find web sites.
    6·1 answer
  • Your company is trying to get out of the responsibility of purchasing and hosting its own hardware so it won’t have to finance o
    13·2 answers
  • A web browser allows you to manage computer files and programs true false
    15·1 answer
  • Write a Python program to do the following:
    12·1 answer
  • Tips for being confident and entertaining when presenting?
    6·1 answer
  • Perform depth-first search on each of the following graphs; whenever there's a choice of vertices, pick the one that is alphabet
    8·1 answer
  • QUESTIONS Which of the following use cases are suitable for compute-optimized cloud offering? ОА. None of the listed O B. Highly
    12·1 answer
  • Que relacion tiene Las palabras: fermentacion-vino y clonacion- dolly​
    9·1 answer
  • What is installing?
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!