Present Value (IN C#) Suppose you want to deposit a certain amount of money into
ID: 3679633 • Letter: P
Question
Present Value (IN C#) Suppose you want to deposit a certain amount of money into a savings account and then leave it alone to draw interest for the next 10 years. At the end of 10 years you would like to have $10,000 in the account. How much do you need to deposit today to make that happen? You can use the following formula, which is known as the present-value formula, to find out. P= F/(1+r)^n The terms in the formula are as follows: P is the present value, or the amount that you need to deposit today. F is the future value, that you want in the account. (In this case, F is $10,000.) r is the annual interest rate. n is the number of years that you plan to let the money sit in the account. Write a method named PresentValue that performs this calculation. The method should accept the future value, annual interest rate, and number of years as arguments. It should return the present value, which is the amount that you need to deposit today. Demonstrate the method in an application that lets the user experiment with different values for the formula's terms.
Explanation / Answer
using System;
class Present
{
public static void Main(string[] args)
{
//intilizing variables
double futureAmount;
double interestRate;
double years;
double answer;
Scanner scan = new Scanner(System.in);
System.out.println("Please the amount of money you would like to have");
futureAmount = scan.nextDouble();
scan.nextLine();
System.out.println("Please enter the interest rate");
interestRate = scan.nextDouble();
scan.nextLine();
System.out.println("Please enter number of years");
years = scan.nextDouble();
Present p=new Present();
answer = p.presentValue(futureAmount, interestRate, years);
System.out.println(answer);
}
public double presentValue(double futureValue,double interestRate,double years)
{
return ((futureValue)/Math.pow((1 + interestRate),years));
}
}