Advertisement
RazorBlade57

Hw #6

Nov 1st, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.76 KB | None | 0 0
  1. //Christopher Clemente
  2. //Comp-171
  3. //Hw #6
  4.  
  5. import java.util.Scanner;
  6. public class Code {
  7.  
  8.     public static void main(String[] args) {
  9.        
  10.         Scanner keyboard = new Scanner(System.in);
  11.        
  12.         int years = 1;
  13.         double investAmount, percentage, futureValue;
  14.        
  15.         System.out.print("Please enter an investment amount :: ");
  16.         investAmount = keyboard.nextDouble();
  17.  
  18.         System.out.print("Enter an annual interest rate :: ");
  19.         percentage = keyboard.nextDouble();
  20.  
  21.         System.out.print("Enter an ammount of years :: ");
  22.         years = keyboard.nextInt();
  23.        
  24.         System.out.println("The initial amount invested was " + investAmount);
  25.        
  26.         System.out.println("The annual interest rate is " + percentage);
  27.        
  28.         System.out.println("Years\t" + "Future Value");
  29.        
  30.         for(int i = 1; i<= years; i++) {
  31.             System.out.println(i + "\t" + "$" + futureInvestmentValue (investAmount, percentage, i));
  32.         }
  33.     }
  34.        
  35.        
  36.    
  37.  
  38.     public static double futureInvestmentValue(double invest, double percentage, double years) {
  39.  
  40.         double futureValue = invest * (Math.pow(1+ (percentage/100)/12, years*12));
  41.         futureValue = (int)(futureValue *100);
  42.         futureValue = futureValue /100;
  43.         return futureValue;
  44.     }
  45.    
  46.    
  47. }
  48.  
  49. /*
  50.  
  51. Please enter an investment amount :: 1000
  52. Enter an annual interest rate :: 9
  53. Enter an ammount of years :: 30
  54. The initial amount invested was 1000.0
  55. The annual interest rate is 9.0
  56. Years   Future Value
  57. 1   $1093.8
  58. 2   $1196.41
  59. 3   $1308.64
  60. 4   $1431.4
  61. 5   $1565.68
  62. 6   $1712.55
  63. 7   $1873.2
  64. 8   $2048.92
  65. 9   $2241.12
  66. 10  $2451.35
  67. 11  $2681.31
  68. 12  $2932.83
  69. 13  $3207.95
  70. 14  $3508.88
  71. 15  $3838.04
  72. 16  $4198.07
  73. 17  $4591.88
  74. 18  $5022.63
  75. 19  $5493.79
  76. 20  $6009.15
  77. 21  $6572.85
  78. 22  $7189.43
  79. 23  $7863.84
  80. 24  $8601.53
  81. 25  $9408.41
  82. 26  $10290.98
  83. 27  $11256.35
  84. 28  $12312.27
  85. 29  $13467.25
  86. 30  $14730.57
  87.  
  88.  */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement