Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Christopher Clemente
- //Comp-171
- //Hw #6
- 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 :: ");
- years = keyboard.nextInt();
- System.out.println("The initial amount invested was " + investAmount);
- System.out.println("The annual interest rate is " + percentage);
- System.out.println("Years\t" + "Future Value");
- for(int i = 1; i<= years; i++) {
- System.out.println(i + "\t" + "$" + futureInvestmentValue (investAmount, percentage, i));
- }
- }
- public static double futureInvestmentValue(double invest, double percentage, double years) {
- double futureValue = invest * (Math.pow(1+ (percentage/100)/12, years*12));
- futureValue = (int)(futureValue *100);
- futureValue = futureValue /100;
- return futureValue;
- }
- }
- /*
- Please enter an investment amount :: 1000
- Enter an annual interest rate :: 9
- Enter an ammount of years :: 30
- The initial amount invested was 1000.0
- The annual interest rate is 9.0
- Years Future Value
- 1 $1093.8
- 2 $1196.41
- 3 $1308.64
- 4 $1431.4
- 5 $1565.68
- 6 $1712.55
- 7 $1873.2
- 8 $2048.92
- 9 $2241.12
- 10 $2451.35
- 11 $2681.31
- 12 $2932.83
- 13 $3207.95
- 14 $3508.88
- 15 $3838.04
- 16 $4198.07
- 17 $4591.88
- 18 $5022.63
- 19 $5493.79
- 20 $6009.15
- 21 $6572.85
- 22 $7189.43
- 23 $7863.84
- 24 $8601.53
- 25 $9408.41
- 26 $10290.98
- 27 $11256.35
- 28 $12312.27
- 29 $13467.25
- 30 $14730.57
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement