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
PLZ HELP WILL GIVE BRAINLIEST!!!!
Natalka [10]
3 i think here is the brainly link where i found tht brainly.com/question/472442     if i helped would you mark me brainiest if i helped?
7 0
3 years ago
A truck was purchased for $25,000 in 2020 and each year its value decreases by 7%. How much will the truck be worth in
spin [16.1K]

Answer:

$3787.5

Step-by-step explanation:

Given data

Cost price=  $25,000

Rate of decrease= 7%

Time= 2020-2026= 26 years

Let us apply the formula

A= P(1-r)^t

substitute

A= 25000(1-0.07)^26

A=25000(0.93)^26

A= 25000*0.1515

A= $3787.5

Hence the worth will be $3787.5

3 0
3 years ago
Layla used 0.482 gram of salt in her experiment. Maurice used 0.51 gram of salt in his experiment. Which pf the following amount
Sedaia [141]
! jdjfcjrwkeodojjweihrbodndjndhicnhwwl
3 0
4 years ago
Read 2 more answers
SimpifyWhat is x to the power of 3 times x to the power 7?
jeka94

Answer:

Here is your solution-

x³ times x⁷

means, x³×x⁷

Here you just have to add the powers as aⁿ×aᵐ=aⁿ⁺ᵐ

x³⁺⁷

x¹⁰

7 0
3 years ago
Read 2 more answers
What is the volume of the square pyramid round to the nearest thenth 10 cm 12 cm 12 cm
oksano4ka [1.4K]

Answer:

Step-by-step explanation:

The formula for determining the volume of a square based pyramid is expressed as

Volume = 1/3 × base area × height

Since the base is a square, all sides would be equal. The formula for finding the area of a square would be applied. From the information given, length of each side of the square is 12 cm. Therefore,

Base area = 12² = 144 cm²

Height = 10 cm

Therefore,

Volume = 1/3 × 144 × 10 = 480 cm³

3 0
3 years ago
Other questions:
  • Which choice is the solution?
    15·1 answer
  • What is:<br> 13 to the 3rd power<br> 2/5 to the second power<br> And 0.9 to the second power
    12·2 answers
  • Give the answer of in the lowest terms 26/25 •15/28•8/39
    12·1 answer
  • I NEED HELP FASTER THAN ASAP
    15·1 answer
  • Is 43 a two digit odd number?
    6·2 answers
  • The sum of two number is 42.Their difference is 12.What are the two numbers?
    11·1 answer
  • EFG has coordinates E(-3, -5), F(-9,1), and G(-6,4). What are the coordinates of the vertices of the image after a reflection in
    7·1 answer
  • What does X equal??<br> Help quick
    7·1 answer
  • What is the 40% of 60
    9·2 answers
  • URGENT HELPP
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!