Create the logic for a program that calculates and displays the amount of money
ID: 3555572 • Letter: C
Question
Create the logic for 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.
I really need the C++ translation, I know that the flowchart and pseudocode can be found elsewhere.
// Pseudocode PLD Chapter 9 #3 pg. 400
// 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
Solution:
Step-1
Here we define FutureValue method like this
float FutureValue(float initialAmount,float interestRate)
{
float finalAmount;
finalAmount=(1+(interestRate/100))*initialAmount;
return finalAmount;
}
Step-2
The main function looks like this
int main()
{
float amount;
float rate;
float newAmount;
cout<<" Please enter the dollar amount ";
cin>>amount;
cout<<" Please enter the interest rate(e.g., nine percent should be entered as 9.0). ";
cin>>rate;
newAmount=FutureValue(amount,rate);
cout<<" The new dollar amount is " <<newAmount;
return 0;
}
Code for the Program
#include <iostream.h>
using namespace std;
float FutureValue(float initialAmount,float interestRate)
{
float finalAmount;
finalAmount=(1+(interestRate/100))*initialAmount;
return finalAmount;
}
int main()
{
float amount;
float rate;
float newAmount;
cout<<" Please enter the dollar amount ";
cin>>amount;
cout<<" Please enter the interest rate(e.g., nine percent should be entered as 9.0). ";
cin>>rate;
newAmount=FutureValue(amount,rate);
cout<<" The new dollar amount is " <<newAmount;
return 0;
}