Advertisement
RazorBlade57

Hw #6

Nov 1st, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.84 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class Code {
  3.  
  4.     public static void main(String[] args) {
  5.        
  6.         Scanner keyboard = new Scanner(System.in);
  7.        
  8.         int years = 1;
  9.         double investAmount, percentage, futureValue;
  10.        
  11.         System.out.print("Please enter an investment amount :: ");
  12.         investAmount = keyboard.nextDouble();
  13.  
  14.         System.out.print("Enter an annual interest rate.");
  15.         percentage = keyboard.nextDouble();
  16.  
  17.         System.out.print("Enter an ammount of years.");
  18.         percentage = keyboard.nextDouble();
  19.        
  20.             System.out.println(calculate(investAmount, percentage, years));
  21.         }
  22.        
  23.        
  24.    
  25.  
  26.     public static double calculate(double a, double b, double c) {
  27.         double futureValue = 0;
  28.         for(int count = 0; count <= c; count++) {
  29.         futureValue = a*Math.pow((1+ b), c * 12);
  30.         System.out.println(futureValue);
  31.         }
  32.         return futureValue;
  33.     }
  34.    
  35.    
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement