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
What are the answers to a, b, c, d?
Nezavi [6.7K]

Answer:

Step-by-step explanation:

8 0
3 years ago
Solve for A in the literal question a/b=c.
Zepler [3.9K]

Answer:

a=bc

Step-by-step explanation:

a/b=c

a=bc

4 0
3 years ago
D)) The ratio of the monthly income and expenditure of Sunayana is 5 : 3. If she
Gnom [1K]

Answer:

Sunayana's income is ₹25000 and expenditures are ₹15000.

Step-by-step explanation:

Let i denote the monthly income and e denote the expenditures.

We know that the ratio of the monthly income to expenditure is 5:3. So, we can write the following proportion:  

\frac{i}{e}=\frac{5}{3}

Let's multiply both sides by e. This yields:

i=\frac{5}{3}e

We know that when the income is <em>increased</em> by 5000 and the expenditures are <em>decreased </em>by 3000, the new ratio is 5:2. So, we can write the following proportion:

\frac{i+5000}{e-3000}=\frac{5}{2}

Let's multiply both sides by (e-3000):

i+5000=\frac{5}{2}(e-3000)

Since we know that i=\frac{5}{3}e, substitute:

\frac{5}{3}e+5000=\frac{5}{2}(e-3000)

So, let's solve for the expenditures. Distribute the right:

\frac{5}{3}e+5000=\frac{5}{2}e-7500

Subtract \frac{5}{2}e from both sides:

-\frac{5}{6}e+5000=-7500

Subtract 5000 from both sides:

-\frac{5}{6}e=-12500

Multiply both sides by -6/5. So, the expenditures are:

e=\text{Rs }15000

We can use the original ratio to find Sunayana's income:

i=\frac{5}{3}e

Substitute 15000 for e. Evaluate:

i=\frac{5}{3}(15000)=\text{Rs }25000

So, Sunayana's income is ₹25000 and expenditures are ₹15000.

And we're done!

Edit: Wrong currency, sorry about that!

3 0
3 years ago
Read 2 more answers
A car travaling 9/10 of miles per minute will travel how many miles in 10 minutes
spin [16.1K]
Answer- i will travel 9 miles in 10 minutes
4 0
3 years ago
Please help!!!!!!!!!
Eddi Din [679]

Answer:

The unknown angle would be 104 degrees

6 0
3 years ago
Read 2 more answers
Other questions:
  • A kennel has eight adult dogs and 14 puppies what is the ratio of adult dogs two puppies use a multiplication to have comparison
    15·1 answer
  • If sin A = 6 over 13, then which of the following is correct?
    7·1 answer
  • A boy gets 560 marks out of 700. What is the percentage of his marks?​
    12·2 answers
  • What is the relationship between the sine and cosine of complementary angles? a They are the same. b They are reciprocals. c The
    5·1 answer
  • I need answer. Please help me.​
    15·2 answers
  • Help ASAP pleaseee lol
    15·1 answer
  • Someone help me it's due today <br>​
    5·1 answer
  • Whats the answer to this plz help​
    14·2 answers
  • -3÷(-2/5) simplify the expression
    12·1 answer
  • PLS HELPPPP I NEED AN ANSWER ASAP WILL GIVE BRAINIEST
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!