23.0k views
0 votes
This code snippet is intended to calculate the balance of an account after twenty years of gaining interest. Select the statement that correctly completes the loop.

int years = 20;
double balance = 10000;
while (years > 0)
{
__________
double interest = balance * rate / 100;
balance = balance + interest;
}

User Nulleight
by
5.3k points

1 Answer

4 votes

Answer:

The answer to this question is the "years--;".

Explanation:

In the given question code the if we define the years--; and the rate of interest in the code so this program will return a value for example if we give rate of interest or rate to value 5 then the output of the code is 26532.977051 because it returns the double that is a floating-point value. So the missing code for this question is "years--;".

User Mehdi Saman Booy
by
5.3k points