Let's modify the program from this section so that the user can supply the interest rate. For very small interest rates, it may take a very long time for the balance to double. Assume the user can't wait for more than twenty years. Stop adding interest when the balance has doubled or twenty years have elapsed. 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27     finaldoubleTARGET=2*INITIAL_BALANCE;   doublebalance=INITIAL_BALANCE; intyear=0;   Scannerin=newScanner(System.in); System.out.print("Interest rate in percent: "); doublerate=in.nextDouble();   // TODO: Count the years required for the investment to double // but no more than 20 years   /* Your code goes here */   System.out.println("Year: "+year); System.out.printf("Balance: %.2f%n", balance); }

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter5: Control Structures Ii (repetition)
Section: Chapter Questions
Problem 21PE
icon
Related questions
Question
100%

Let's modify the program from this section so that the user can supply the interest rate. For very small interest rates, it may take a very long time for the balance to double. Assume the user can't wait for more than twenty years. Stop adding interest when the balance has doubled or twenty years have elapsed.

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
 
 
finaldoubleTARGET=2*INITIAL_BALANCE;
 
doublebalance=INITIAL_BALANCE;
intyear=0;
 
Scannerin=newScanner(System.in);
System.out.print("Interest rate in percent: ");
doublerate=in.nextDouble();
 
// TODO: Count the years required for the investment to double
// but no more than 20 years
 
/* Your code goes here */
 
System.out.println("Year: "+year);
System.out.printf("Balance: %.2f%n", balance);
}
 
 
 
Let's modify the program from this section so that the user can supply the interest rate. For very small interest rates, it may take a
very long time for the balance to double. Assume the user can't wait for more than twenty years. Stop adding interest when the
balance has doubled or twenty years have elapsed.
2
11
12
double balance
INITIAL_BALANCE;
4
13
int year
0;
14
Scanner in
= new Scanner(System.in);
System.out.print("Interest rate in percent: ");
in.nextDouble();
15
16
17
double rate
18
// TODO: Count the years required for the investment to double
// but no more than 20 years
19
20
21
22
/* Your code goes here */
23
System.out.println("Year:
System.out.printf("Balance: %.2f%n", balance);
+ year);
24
25
26
1
2
3
4
Transcribed Image Text:Let's modify the program from this section so that the user can supply the interest rate. For very small interest rates, it may take a very long time for the balance to double. Assume the user can't wait for more than twenty years. Stop adding interest when the balance has doubled or twenty years have elapsed. 2 11 12 double balance INITIAL_BALANCE; 4 13 int year 0; 14 Scanner in = new Scanner(System.in); System.out.print("Interest rate in percent: "); in.nextDouble(); 15 16 17 double rate 18 // TODO: Count the years required for the investment to double // but no more than 20 years 19 20 21 22 /* Your code goes here */ 23 System.out.println("Year: System.out.printf("Balance: %.2f%n", balance); + year); 24 25 26 1 2 3 4
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT