Advertisement
Guest User

IRA Interest Calculator

a guest
May 5th, 2015
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.04 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3.  
  4. class IRAInterestCalculator {
  5.  
  6.  
  7.     public static void main(String[] args){
  8.  
  9.         double interestRate;
  10.         double accountValue = 0;
  11.         double yearlyDeposit;
  12.         int years;
  13.         int ycounter;
  14.  
  15.         Scanner scan = new Scanner(System.in);
  16.  
  17.  
  18.         System.out.print("Enter the yearly deposit into the account: ");
  19.         yearlyDeposit = scan.nextDouble();
  20.  
  21.         System.out.print("Enter the yearly interest rate of the account as a percent: ");
  22.         interestRate = (scan.nextDouble() / 100) + 1;
  23.  
  24.         System.out.print("Enter the number of years to which to calculate: ");
  25.         years = scan.nextInt();
  26.  
  27.         System.out.println("====================================");
  28.  
  29.  
  30.         for(ycounter=1;ycounter<=years;ycounter++){
  31.  
  32.             accountValue += yearlyDeposit;
  33.             accountValue *= interestRate;
  34.  
  35.             System.out.println("Year " + ycounter + ": \t $" + accountValue);
  36.  
  37.         }
  38.  
  39.         System.out.println("====================================");
  40.  
  41.         System.out.println("After " + years + " years, you have earned $" + accountValue + ". You're rich!");
  42.  
  43.  
  44.  
  45.     }
  46.  
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement