Advertisement
Guest User

Untitled

a guest
Mar 30th, 2020
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.77 KB | None | 0 0
  1. public void compoundAnnual() {
  2.   double investment = 1000;
  3.   int year = 25;
  4.   double newDeposit = 0;
  5.   double newBalance;
  6.   double interestRate = 6.5;
  7.   double interest;
  8.   double deposit = 0;
  9.  
  10.  
  11.  
  12.     System.out.println("Year    Interest      New Deposit        New Balance");
  13.     System.out.println("------------------------------------------------------");
  14.  
  15.     for (int i = 1; i <= year; i++) {
  16.         if (i == 1)
  17.         {
  18.  
  19.             newDeposit = investment;
  20.         }
  21.         newBalance = newDeposit * Math.pow((1 + (interestRate/100)), 1);
  22.  
  23.         interest = newBalance - newDeposit;
  24.  
  25.         System.out.printf("%1d    %10.2f   %20.2f    %22.2f \n ", i, interest, newDeposit, newBalance);
  26.  
  27.  
  28.         newDeposit = newBalance + 100;            
  29.     }    
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement