-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathpresentValue.java
More file actions
39 lines (27 loc) · 1.22 KB
/
presentValue.java
File metadata and controls
39 lines (27 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import java.util.Scanner;
import static java.lang.Math.pow;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Me
*/
public class presentValue {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Enter the Furture Value."); // gets FV
double futureValue = input.nextDouble();
System.out.println("Enter the Interest Rate.");// gets rate
double interestRate = input.nextDouble();
System.out.println("Enter the number of years. "); //gets time
double time = input.nextDouble();
System.out.println(presentValue(futureValue, interestRate, time)); // Print to screen the present value
}
public static double presentValue(double futureValueR, double interestRateR, double yearsR) {
// System.out.println( " future: "+futureValueR +" rate: "+ interestRateR +" years: "+ yearsR); //Tests the arguments
return futureValueR / Math.pow((1 + interestRateR), yearsR); // Will return the present Value
}
}