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
How many lines of symmetry does the letter x have
lana [24]
The letter x has two lines of symmetry.
8 0
3 years ago
Read 2 more answers
A street sign is 99 inches tall. How tall is it in feet and Inches?
erastova [34]

Answer:

8 feet and 3 inches

Step-by-step explanation:

You need to divide 99 by 12

7 0
3 years ago
Read 2 more answers
Olga’s family traveled 942 kilometers on the first day of their trip and 894.5 kilometers on the second day. How many more meter
lawyer [7]
47,500 hope i helped have a snazzy day
8 0
3 years ago
Read 2 more answers
Item 8
SCORPION-xisa [38]

53 minutes

3:08 to 4:00 is 52 minutes.

to 4:01 would add an extra minute which would be 53.

6 0
3 years ago
Read 2 more answers
7 times the number of cookies in the jar plus 5 more from the tray is 54. How many cookies are in the jar?
Digiron [165]

Answer:

The number of cookies in the jar is 7.

If we include the 5 cookies from the tray in the jar the total number of cookies would be 5 + 7 = 12

Step-by-step explanation:

<em>Consider the number of cookies in the jar as 'x'. Hence the equation formed would be:-</em>

7(x) + 5 = 54

7x + 5 = 54

7x = 54 - 5

7x = 49

x = \frac{49}{7}

x = 7

The number of cookies in the jar is 7.

If we include the 5 cookies from the tray in the jar the total number of cookies would be 5 + 7 = 12

<em>Hope this helps.</em>

8 0
3 years ago
Other questions:
  • A computer company makes a rectangular screen with a diagonal of 20 inches. The width of the screen is 4 inches less than its le
    11·2 answers
  • The graph of f(x) = 2x3 – 19x2 + 57x – 54 is shown below. mc018-1.jpg How many roots of f(x) are rational numbers?
    15·2 answers
  • (2a2 + ab + 2b) + (4a2 − 3ab + 9)
    12·1 answer
  • 1 quart of milk into 4 bottle i had 1/4 milk how many ounces pour into each bottle
    6·1 answer
  • If a company has 150 shares of common stock and $15000.00 to be distributed to its holders, how much each share receive
    15·2 answers
  • PLEASE HELP ME!!!! 20 POINTS
    6·2 answers
  • Why does it take 3 copies of 1/6 to show the same amount as 1/2
    9·2 answers
  • Select the correct answer.
    14·1 answer
  • Xe^(-x^2/128) absolute max and absolute min
    10·1 answer
  • Peter earns $32,000 per year plus a 2.5% commission on his jewelry sales. Find Peter's total salary for the year when his sales
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!