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
The lines shown below are parallel. If the green line has a slope of -14, what
Goshia [24]

Answer:

-1/11

Step-by-step explanation:

Parallel lines have the same slope, but different y-intercepts. So, if the slope of the green line is -1/11, then the slope of the red line would also be -1/11.

6 0
3 years ago
Deon plans to ride a 20-mi bicycle trail. If his average speed is 10 mi/h, how many hours will the ride take? Part 1: Solve the
pentagon [3]

Answer:

The ride will take 2 h

Step-by-step explanation:

From the question,

Deon plans to ride a 20-mi bicycle trail, that is the total distance he plans to cover is 20-mi

Distance, d = 20 mi

Also, his average speed is 10 mi/h

rate of speed, r = 10 mi/h

To determine how many hours the ride will take,

From the formula,

d = rt

where

d is the distance covered

r is the average rate of speed

and t is the time.

We can solve for t, such

d = rt becomes

t = d/r

Now, from the question

d = 20 mi

r = 10 mi/h

∴ t = (20 mi) / (10 mi/h)

t = 2 h

Hence, the ride will take 2 h (hours)

7 0
3 years ago
What is the area of this triangle?
Ludmilka [50]

Answer:

area = 1/2 *base* height

= 1/2 * 12* 9

= 54 cm^2

right triangle...

Hope this helps...

3 0
2 years ago
Need help with this
Zigmanuir [339]
In the ones place its 1

hundreds =  5
thaosands = 4
3 0
3 years ago
What is the equation of the line that passes through the point (-5,-2) and has a slope of -6/5
tatyana61 [14]

Answer:

The answer is

<h2>y =  -  \frac{6}{5} x - 8  \\</h2>

Step-by-step explanation:

To find an equation of a line in point slope form when given the slope and a point we use the formula

y -  y_1 = m(x -  x_1) \\

where

m is the slope

( x1 , y1) is the point

From the question the point is (-5,-2) and the slope is - 6/5

The equation of the line is

y + 2 =  -  \frac{6}{5} (x + 5) \\ y + 2  =  -  \frac{6}{5} x - 6 \\ y =  -  \frac{6}{5} x - 6 - 2

We have the final answer as

y =  -  \frac{6}{5} x - 8  \\

Hope this helps you

5 0
3 years ago
Other questions:
  • maria is bringing her sick dog pedro in for a series of appointments at the veterinary clinic. Her total over the course of trea
    5·1 answer
  • Which statement about the points (0, 3), (2, 8), (8, 2), and (0, 1) is true?
    10·2 answers
  • 1.21 liters = centiliters​
    14·1 answer
  • The slope of the line passing through the points (-1, 5) and (1, 6) is no slope 1/2 5/4
    9·2 answers
  • ursula earns $9 per hour.to write an expression that tells how much ursula earns h hours,joshua wrote 9/h.sarah wrote 9h. hwose
    6·1 answer
  • An________contains a whole number part and a fraction part
    10·1 answer
  • I need help with this please
    12·1 answer
  • Which values from the set {-6,-4,-3, -1 0 and 2} satisfy this inequlity? -1/2x+3&gt;5
    12·1 answer
  • In a school, 50% of students are younger of students younger than 10, 1/2 are 10 years old and 1/10 are older than 10 but younge
    9·1 answer
  • The dot plots below show the scores for a group of students for two rounds of a quiz:
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!