Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.76 KB | None | 0 0
  1.     public static void calcInterest() {
  2.        
  3.         double balance;
  4.         double balance1;
  5.         double balance2;
  6.         double balance3;
  7.         double rate;
  8.         int interest;
  9.        
  10.         Scanner input = new Scanner(System.in);
  11.         System.out.println("Enter your initial balance: ");
  12.         balance =  input.nextDouble();
  13.         System.out.println("What is the percentage of the yearly rate of interest? ");
  14.         interest = input.nextInt();
  15.        
  16.         rate = (interest / 100.0);
  17.        
  18.         balance1 = balance + (balance * rate);
  19.         balance2 = balance1 + (balance1 * rate);
  20.         balance3 = balance2 + (balance2 * rate);
  21.        
  22.        
  23.         System.out.println("Balance after 1 year: " + balance1);
  24.         System.out.println("Balance after 2 years: " + balance2);
  25.         System.out.println("Balance after 3 years: " + balance3);
  26.  
  27.        
  28.        
  29.        
  30.        
  31.  
  32.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement