Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Code {
- public static void main(String[] args) {
- Scanner keyboard = new Scanner(System.in);
- int years = 1;
- double investAmount, percentage, futureValue;
- System.out.print("Please enter an investment amount :: ");
- investAmount = keyboard.nextDouble();
- System.out.print("Enter an annual interest rate.");
- percentage = keyboard.nextDouble();
- System.out.print("Enter an ammount of years.");
- percentage = keyboard.nextDouble();
- System.out.println(calculate(investAmount, percentage, years));
- }
- public static double calculate(double a, double b, double c) {
- double futureValue = 0;
- for(int count = 0; count <= c; count++) {
- futureValue = a*Math.pow((1+ b), c * 12);
- System.out.println(futureValue);
- }
- return futureValue;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement