Advertisement
vp0415

lec4.2

Oct 31st, 2014
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.36 KB | None | 0 0
  1. public class Interest {
  2.  
  3.     public static void main(String[] args) {
  4.         double amount;
  5.         double principal = 1000.0;
  6.         double rate = 0.05;
  7.         System.out.printf("%s%20s\n", "Year", "Amount on deposit");
  8.         for (int year = 1; year<= 10; year++)
  9.         {
  10.         amount = principal * Math.pow(1.0 + rate, year);
  11.         System.out.printf("%4d%,20.2f\n", year, amount);
  12.         }
  13.     }
  14.  
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement