Java 5.18 Modified Compound Interest Program- Modify the application in Fig 5.6 to use only integers to calculate the compound interest.[Hint: Treat all monetary amounts as integral numbers of pennies. Then break the result into its dollar and cents portions by using the division and remainder operations, respectively. Insert a period between the dollar and cents portion.] Ex. output $100.26
Fig 5.6
public class Modified_Compound_Interest_Program {
public static void main(String[] args) {
double amount; //amount on deposit at end of each yeardouble principal = 1000.0; //initial amount before interestdouble rate = 0.05; //interest rate
//display headersSystem.out.printf("%s%20s%n", "Year", "Amount on deposit");
//calculate amount on deposit for each of ten yearsfor (int year = 1; year <=>{//calcualte new amount for specified yearamount = principal * Math.pow(1.0 + rate, year);
//display the year and the amountSystem.out.printf("%4d%,20.2f%n", year, amount);}}} // end of class
=>
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here