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
Brooke is paving a parking spot shown below. It costs $40 to pave each square meter.
lozanna [386]
Benenjnrmmrjrbr fbjrrkjen r their
5 0
3 years ago
The graph shows the height in feet of an object
Alexus [3.1K]

Answer:

h(t)= -167 +128t -256 gfgeggd

3 0
3 years ago
Read 2 more answers
Find x if x-log 48 + 3 log 2 = 1/3log125 - log3
Llana [10]

Answer:

Step-by-step explanation:

x−log(48)+3(log(2))=

1

3

(log(125))−log(3)

Simplifies to:

x−0.778151=0.221849

Let's solve your equation step-by-step.

x−0.778151=0.221849

Step 1: Add 0.778151 to both sides.

x−0.778151+0.778151=0.221849+0.778151

x=1

Answer:

x=1

 

7 0
3 years ago
Simpily the expression below: 2(4x + 5y)​
wolverine [178]

Answer: 8x+10y

Step-by-step explanation:

2(4x)= 8x

2(5y)= 10y

8x+10y

6 0
3 years ago
Complete the sentence with the correct item:
lana [24]
A COEFFICIENT is the numerical factor of a multiplication expression like 3x.

Parts of a multiplication expression.

3x + 6

3 is the coefficient
x is the variable
6 is the constant

3x and 6 are called terms.
7 0
3 years ago
Other questions:
  • Find the area of an equilateral triangle (regular 3-gon) with the given measurement.
    12·1 answer
  • What is the LCM for 3/4 and 5/6
    7·2 answers
  • Need help with this question please for a grade
    7·1 answer
  • A student finds the slope of the line between (8, 17) and (1, 4). She writes 17-4/1-8 What mistake did she make?
    8·2 answers
  • A garden table and a bench cost $746 combined. The garden table costs $96 more than the bench. What is the cost of the bench?
    6·1 answer
  • A 400g loaf of white bread contains 228 g of flour. An 800 g loaf of brown
    6·1 answer
  • PLEASE HELP!
    5·1 answer
  • What is the measure of the indicated central angle ?
    5·1 answer
  • PLEASE HELP ME!!!! <br><br>ILL GIVE BRAINLIEST<br>​
    6·1 answer
  • PLEASE ILL MARK AS BRAINLIEST OR EXTRA POINTS DUE IN 10 MINUTES!
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!