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...



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<br>very long time for the balance to double. Assume the user can't wait for more than twenty years. Stop adding interest when the<br>balance has doubled or twenty years have elapsed.<br>2<br>11<br>12<br>double balance<br>INITIAL_BALANCE;<br>4<br>13<br>int year<br>0;<br>14<br>Scanner in<br>= new Scanner(System.in);<br>System.out.print(

Extracted 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
Jun 11, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions ยป

Submit New Assignment

Copy and Paste Your Assignment Here