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 MARK BRAINLIEST!!!!!!!!!!!!
aalyn [17]

Answer:

x+y=1+3

Step-by-step explanation:

6 0
3 years ago
What ratio can you use to determine the probability of a compound event?
maria [59]

Answer:

Step-by-step explanation:

Favorable outcome. To possible outcome

4 0
3 years ago
Which strategy would you use to find 2plus8?explain
nika2105 [10]
it is 10...,,,,....,,,,,,,,,,?,,?????
8 0
3 years ago
What is the value of x enter your answer in the Box
lina2011 [118]
The x is 176.54 cm.
i use pythagorean thearem
{c}^{2}  =  {a}^{2}  +  {b}^{2}

4 0
3 years ago
Read 2 more answers
To convert 70 minutes to seconds, you would use the ratio a. true b. false
Angelina_Jolie [31]
True, you would use the ratio of minutes to seconds.
8 0
3 years ago
Other questions:
  • Solving slope (1,1/2),(3,2)
    10·1 answer
  • Pizzas come in 4 different sizes, each with or without a choice of 5 toppings. How many ways are there to order a pizza?
    6·1 answer
  • Donna is running a track it takes her 10 minutes to run 6 laps if she keeps running at the same speed how long will it take her
    12·2 answers
  • Which number should be added to both sides of the equation to complete the square x^2-10x=7
    13·1 answer
  • Can someone help I have to be done by tomorrow morning plz order them from least to greatest plz
    11·1 answer
  • Help please for 40 points!! This is due tonight and i don’t know how to do it
    13·1 answer
  • Cuanto es 91972×898972819
    13·1 answer
  • 17x2 + 7x - 14<br> This algebra 1
    10·1 answer
  • Brainliest goes to whoever answers correctly try to show work ONLY if you can
    14·1 answer
  • HELP TAKE YOUR TIME°!!!<br><br><br> FOR MY SISTER
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!