Advertisement
Guest User

Untitled

a guest
Mar 30th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. double initialSavings;
  2. System.out.print("How much money would you like to save each month? $");
  3. initialSavings = userInput.nextDouble();
  4.  
  5. double annualInterest;
  6. System.out.print("What is the annual interest rate for your savings account? (Example, 2.5) ");
  7. annualInterest = userInput.nextDouble();
  8.  
  9. int months;
  10. System.out.print("How many months would you like to keep saving? ");
  11. months = userInput.nextInt();
  12.  
  13. double monthlyInterest;
  14. monthlyInterest = annualInterest / 12;
  15.  
  16. int count = 1;
  17.  
  18. while (count <= months) {
  19.  
  20. count++;
  21.  
  22. double result;
  23.  
  24. result = initialSavings * count * (1 + monthlyInterest);
  25.  
  26. }
  27.  
  28. System.out.println("You will have $"+ result "after "+ months "months.");
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement