I need to know how to input the following code into the complier for C++ code. I
ID: 3857862 • Letter: I
Question
I need to know how to input the following code into the complier for C++ code. It is for Chapter 9 in the PLD book question #3.
// 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;
float FutureValue(int amount, float interestRate);
int main()
{
float amount, newAmount, interestRate;
cout<<" Please enter the Dollar Amount: ";
cin>>amount;
cout<<" Please enter the interest rate (Eg: nine percent should be entered as 9.0: ";
cin>>interestRate;
newAmount = FutureValue(amount, interestRate);
cout<<" The new dollar amount is: " <<newAmount;
return 0;
}
float FutureValue(int initialAmount, float interestRate)
{
float finalAmount;
finalAmount = (1 + interestRate/100) * initialAmount;
return finalAmount;
}
OUTPUT
Please enter the Dollar Amount: 65
Please enter the interest rate (Eg: nine percent should be entered as 9.0: 9.0
The new dollar amount is: 70.85