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
valentinak56 [21]
3 years ago
9

What is the result when the following code is run? double x = 1; double y = 1; int i = 0; do { y = x / 2; x = x + y; i = i + 1;

} while (x < 2.5); System.out.print(i + " ");
Mathematics
1 answer:
Mama L [17]3 years ago
6 0

Answer:

The answer is: 3

Step-by-step explanation:

1. At the begining of the program we start by declairing the variables:

 double x=1, double y=1 and int i=0.

2. The structure do...while is used to defined the loop. x<2.5 is the finalization condition of the loop. i is the counter of the loop.

y=x/2 is the first calculation

x=x+y is the second one. Here is where the values of the variable x changes.

a) for the first iteration, the values of y and x are shown below:

\\\\x=1\\y=1\\y=1/2=0.5\\x=1+0.5=1.5\\i=1

The variable x is minor to 2.5 so the loop will continue computing.

b)   the second iteration, the values of y and x are shown below::

 y=0.5\\x=1.5\\y=\frac{1.5}{2}=0.75\\ x=1.5+0.75=2.25\\i=2

The variable x is still minor to 2.5 so the loop will continue computing.

c) third iteration:

y=0.75\\x=2.25\\y=\frac{2.25}{2} =1.1125\\x=2.25+1.125=3.375\\i=3

The condition x<2.5 is not true so the loop ends.

3. System.out.print(i + " "); displays the value of the variable i wich value is 3.

Therefore the number 3 is display.

You might be interested in
Will try to mark the right answer brainiest || What's the slope of this line?
Aliun [14]

Answer:

the slope of the line is 2/3x

Step-by-step explanation:

i hope this helps :)

8 0
3 years ago
Solve the following problem.
Serggg [28]
<span>It costs 19.48, because $16,421.40 / 843 comes out to 19.479, and 19.479 rounds to 19.48. So the answer is B $19.48.

Hope this helps :)</span>
8 0
3 years ago
Read 2 more answers
What is the image of the point (-5, -9) after a rotation of 90° counterclockwise
Andrej [43]

Answer:

5,-9

Step-by-step explanation:

6 0
2 years ago
What is the percent of decrease from 500,000 to 200,000?
ad-work [718]

Answer:

500,000 to 200,000 is a 60% decrease.

6 0
2 years ago
Tell whether the ratios form a proportion<br><br> Someone please help!
DanielleElmas [232]
No because they do not have the same factors
3 0
3 years ago
Other questions:
  • Find the slope of the line that passes through the pair of points.<br> (4,8), (8, 11)
    11·1 answer
  • Find all numbers whose absolute value is 6​
    13·1 answer
  • Given AABC with vertices A(-3,3), B(2,4), and C(3,-1), what is the area of ABC?
    10·1 answer
  • This week Kent worked 15 hours at $12.50 an hour. His paycheck, including his commission, was $263.85. Ken wants to
    10·2 answers
  • .60 is what percent of 180? ​
    15·2 answers
  • Determine the equation of the inverse of:<br> f(x) = 5x^2+ 80x – 15
    15·1 answer
  • Hey plz anyone inbox me ​
    11·2 answers
  • Simplify x^6+10x^5+25x^4-x^2-10x-25 using synthetic division
    11·1 answer
  • Can you help me on question 25?!
    14·1 answer
  • Bro, I hate these questions.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!