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
A juice pitcher holds 1.5 gallons of liquid. How many 8-ounce glasses of juice can be poured from a full pitcher? (1 gallon = 12
larisa86 [58]
1gallon=128ounces\\To\ receive\ volume\ of\ pitcher\ in\ onces\ we\ need\ to\ multiply\ its\\volume\ in\ gallons\ by\ ounces\ in\ 1\ gallon.\\1,5g=1,5*128=192o\\Now\ to\ receive\ answer\ we\ need\ to\ divide\ volume\ of\ pitcher\ in\\ounces\ by\ volume\ of\ glass.\\192:8=24\\\\We\ need\ to\ 24\ glasses.
6 0
3 years ago
Which ratio is equivalent to 6 : 7? A. 12 : 13 B. 18 : 48 C. 36 : 49 D. 48 : 56
lara [203]
The answer is D. The answer is D because you just keep multiplying each number by the same number.

6 • 8 = 48
7 • 8 = 56
6 0
3 years ago
Please help me this is my last question this one is worth big points for me
Allushta [10]

Answer: your gonna add 3,000+ 5,000 then you will add test answer to 157.50 then you’ll put the answer for 3,000+5,000 then you’ll put that in the first box then you’ll add that number two 157.50

Step-by-step explanation:

Hope this helps

:3 have an amazing day or a beautiful day:)

3 0
2 years ago
WILL GIVE BRAINLIEST AND 20 POINTS!
strojnjashka [21]
Y= - 3/4 x + 15/8

hope that helps
3 0
3 years ago
Read 2 more answers
What is the range of the relation below?
Sedbober [7]
The pictures aren’t posted
8 0
2 years ago
Read 2 more answers
Other questions:
  • Jon has to pay $7.50 admission for the skating rink and $1.50 per hour to rent rollerblades. Write an equation for the cost (y)
    10·1 answer
  • Pleaseeee help meeeeeee
    5·1 answer
  • A television network is deciding whether or not to give its newest television show a spot during prime viewing time at night. If
    14·1 answer
  • What is the first step in finding the unit price on a box of 20 pencils?
    14·1 answer
  • What is the solution for x in -10x+6y=-28
    13·1 answer
  • What is the next terms in<br> the sequence :5;9;13;17​
    5·2 answers
  • Solve for b: A= (h(a+b))/2
    6·1 answer
  • The Lylian is one of several methods claimed to increase the likelihood of a baby girl. In a clinical trial, results could be an
    8·1 answer
  • You deposit $650 in a savings account. How long does it take an account with an annual interest rate of 5% to earn $178.25 in in
    13·1 answer
  • Lilo has 1,000 minutes per month on her cell phone plan. Write and solve an inequality showing the maximum number of minutes tha
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!