C using method Create a new Console application named Presen

C#, using method:

Create a new Console application named PresentValue. 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 ten years, you would like to have $10,000 in the account. How much would 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 you would 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 savings account. Write a value returning method named GetPresentValue 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. Display the present value in currency format.

Solution

PresentValue.cs

using System.IO;
using System;

class PresentValue
{
static void Main()
{
Console.Write(\"Enter future value: \");
int F=Convert.ToInt32(Console.ReadLine());
Console.Write(\"Enter annual interest rate: \");
double r=Convert.ToDouble(Console.ReadLine());
  
Console.Write(\"Enter number of years: \");
int n=Convert.ToInt32(Console.ReadLine());
double d =GetPresentValue(F,r,n);
  
Console.WriteLine(\"You would need to deposit: \"+d);
}
static double GetPresentValue(int F, double r, int n){
return F / (Math.Pow((1 + (r/100.0)), n));
}
}

Output:

Enter future value: 10000

Enter annual interest rate: 1.5

Enter number of years: 10

You would need to deposit: 8616.67

C#, using method: Create a new Console application named PresentValue. Suppose you want to deposit a certain amount of money into a savings account and then lea

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site