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
Solve the following eqation for x: 6(4x+5)+3=3(x+8)+3. Round to the nearest hundredth
netineya [11]

24x + 33 = 3x + 27

21x + 33 = 27

21x = -6

X = -.29

7 0
3 years ago
Read 2 more answers
Why does cos(90°) = 0?
Anestetic [448]

Answer:

Step-by-step explanation:

The horizontal leg is 0, since there is no horizontal component of the triangle, so, the cosine is 0. Consider the angle itself and the unit circle. There is no horizontal component of the angle: The horizontal component of the angle is 0, so, the cosine of 90° is 0.

4 0
3 years ago
Decide whether the two inequalities are equivalent. Explain.
zhenek [66]

Answer:

D,no if you graph both inequalitiesvon thevsame geaph ,you will get b =16

6 0
2 years ago
Find the area. Answer without units.<br><br>I need this asap thx (:
finlep [7]

Answer:

I think the answer is 43.8

5 0
2 years ago
Read 2 more answers
Find the volume of the cylinder.<br> Either enter an exact answer in terms of or use 3.14
kow [346]

Answer: 400

Step-by-step explanation:

5 0
3 years ago
Read 2 more answers
Other questions:
  • A square has a side of 6.25 feet. What is the area in square feet? Round to the correct significant digits.
    11·2 answers
  • Whats the answer to (2w - 9) + (-4w -5)
    6·2 answers
  • The graph below shows the relationship between the number of dollars x and the number of tickets you can buy y. Tell whether the
    15·1 answer
  • 6x^2-x&lt;2 solve, show your answer on a number line. State your answer in interval notation
    5·1 answer
  • Help please I rly need it <br>60 POINTSS​
    5·2 answers
  • A patient is to receive Taxol 100 mg/m2. The patient weighs 120 lbs and is 5'8" tall. What dose of Taxol in milligrams should th
    6·1 answer
  • Describe the process for<br> graphing the equation<br> y =-1/2x- 1
    14·1 answer
  • Acceleration of a runner who goes from 1.4 m/s to 2.2 m/s in 4 s
    13·1 answer
  • I can correctly re-write the expression 56 + 48 as _____
    6·1 answer
  • Please help me with this math please please asap please
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!