Advertisement
Guest User

Untitled

a guest
May 6th, 2020
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.61 KB | None | 0 0
  1. public static void No50 () {
  2.         final double initialCapital = 223.12;
  3.         final double interestRate = 1.5;
  4.  
  5.         final int years = 3; //change years
  6.         double capital = initialCapital; //init capital and sets value
  7.  
  8.         System.out.println("Initial capital:" + initialCapital);
  9.         System.out.println("Annual interest rate:" + interestRate);
  10.  
  11.         for(int i = 0; i < years; i++) { //loop through all years
  12.             capital *= (1 + interestRate/100); //multiple  Rate to capital
  13.         }
  14.  
  15.         System.out.println("Capital after " + years + " years:" + capital); //Print Rate
  16.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement