Create a program that calculates and displays the amount of money you would have
ID: 3547135 • Letter: C
Question
Create a program that calculates and displays the amount of money you would have if you invested $5000 at 2 percent simple interest for one year.Create a separate method to do the calculation and return the result to be displayed. Use the following Pseudocode:
// Start
// Declarations
// num amount
// num newAmount
// num interestRate
// output "Please enter the dollar amount. "
// input amount
// output "Please enter the interest rate(e.g., nine percet should be entered as 9.0). "
// input interestRate
// newAmount = FutureValue(amount,interestRate)
// output "The new dollar amount is ", newAmount
// Stop
//
//
//
// num FutureValue(num initialAmount, num interestRate)
// Declarations
// num finalAmount
// finalAmount = (1 + interestRate/100) * initialAmount
// return finalAmount
Explanation / Answer
#include <iostream>
using namespace std;
double FutureValue(double initialAmount, double interestRate);
int main()
{
double amount;
double newAmount;
double interestRate;
cout << "Please enter the dollar amount. " << endl;
cin >> amount;
cout << "Please enter the interest rate(e.g., nine percet should be entered as 9.0). " << endl;
cin >> interestRate;
newAmount = FutureValue(amount, interestRate);
cout << "The new dollar amount is " << newAmount << endl;
}
double FutureValue(double initialAmount, double interestRate)
{
double finalAmount;
finalAmount = (1 + interestRate/100) * initialAmount;
return finalAmount;
}
//test run and proper indentation: http://ideone.com/qsC6Q6
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.