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)" 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.
showing a User Interface with sample data entered and calculated as well
Please use C# in Microsoft Visual Studios and add.
Also, please add comments, too! Thank you and have a good one!


Since you asked the program in C#. I have provided the code.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
namespace PresentValue
{
public partial class Form
{
public Form()
{
InitializeComponent();
}
private void calc(object sender, EventArgs e)
{
//declare variables
double futureValue = 0;
double interest = 0;
int years = 0;
//Extract and convert to corresponding data types
futureValue = Convert.ToDouble(futureTxt.Text);
interest = Convert.ToDouble(interestTxt.Text );
years = Convert.ToInt32(yearsTxt.Text);
//Call the method PresentValue
double presentValue = PresentValue(futureValue, interest, years);
//Set presentValue to the label
presentLabel.Text = "Present value for invest : "+presentValue.ToString("C2");
}
//This method PresentValue that takes double future value, interest rate and years as intputs and calculate the present value and returns .
private double PresentValue(double futureValue, double interest, int years)
{
double presenetvalue = futureValue / Math.Pow((1 + interest), years);
return presenetvalue;
}
}
}
Step by step
Solved in 2 steps with 1 images









