Respuesta :
Answer:
//Import the Scanner class
import java.util.Scanner;
//Class definition
public class FutureValue {
//main method declaration
public static void main(String[] args) {
//Create an object of the Scanner class
Scanner input = new Scanner(System.in);
//Prompt the user to enter the future value
System.out.println("Please enter the future value");
//Store the user input in a variable
double futurevalue = input.nextDouble();
//Prompt the user to enter the annual interest rate
System.out.println("Please enter the annual interest rate");
//Store the user input in a variable
double annualrate = input.nextDouble();
//Promppt the user to enter the number of years
System.out.println("Please enter the number of years");
//Store the user input in a variable
double numberofyears = input.nextDouble();
//Now use the given formula to calculate t he amount to store now (present value)
double presentvalue = futurevalue / Math.pow((1 + annualrate), numberofyears);
//Display the result
System.out.println("The present value of money should be " + presentvalue);
}
}
============================================================
Sample Output 1:
>> Please enter the future value
100000
>> Please enter the annual interest rate
9
>> Please enter the number of years
2
>> The present value of money should be 1000.0
=============================================================
Sample Output 2:
>> Please enter the future value
2000000
>> Please enter the annual interest rate
4
>> Please enter the number of years
3
>> The present value of money should be 16000.0
Explanation:
The code above has been written in Java. It contains comments explaining every segment of the code. Please go through the comments for explanation. Sample outputs have always been provided.
The actual lines of code have been written in bold-face to distinguish it from the comments.