Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- double initialSavings;
- System.out.print("How much money would you like to save each month? $");
- initialSavings = userInput.nextDouble();
- double annualInterest;
- System.out.print("What is the annual interest rate for your savings account? (Example, 2.5) ");
- annualInterest = userInput.nextDouble();
- int months;
- System.out.print("How many months would you like to keep saving? ");
- months = userInput.nextInt();
- double monthlyInterest;
- monthlyInterest = annualInterest / 12;
- int count = 1;
- while (count <= months) {
- count++;
- double result;
- result = initialSavings * count * (1 + monthlyInterest);
- }
- System.out.println("You will have $"+ result "after "+ months "months.");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement