Question: Modify the application in Fig. 4.6 to use only integers to calculate the compound interest. Treat all monetary amounts as integral numbers of pennies. Then

Modify the application in Fig. 4.6 to use only integers to calculate the compound interest. Treat all monetary amounts as integral numbers of pennies. Then break the result into its dollars and cents portions by using the division and remainder operations, respectively. Insert a period between the dollars and the cents portions.

 Fig. 4.6

I // Fig. </p>                                                    <button class=Transcribed image text

I // Fig. 4.6: Interest.java 2 // Compound-interest calculations with for.. 3 4 5 6 7 8 9 10 12 13 14 public class Interest { public static void main (String[] args) { double principal = 1000.0; // initial amount before interest double rate= 0.05; // interest rate 15 16 17 18 19 20 21 } 1 234567899 } 10 // display headers System.out.printf("%s%20s%n", "Year", "Amount on deposit"); Year Amount on deposit 1,050.00 1,102.50 1,157.63 1,215.51 1,276.28 1,340.10 1,407.10 1,477.46 // calculate amount on deposit for each of ten years for (int year = 1; year

Step by Step Solution

3.45 Rating (148 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Certainly To modify the ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Java How To Program Late Objects Questions!