int main( )
{
// Declarations
// num amount
// num newAmount
// num interestRate
int amount;
int newAmount;
int 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
cout << "Please enter dollar amount. " << endl;
cin >> amount;
cout << "Please enter the interest rate(e.g., nine percent should be entered as 0.9). " << endl;
cin >> interestRate;
// newAmount = FutureValue(amount,interestRate)
// output "The new dollar amount is ", newAmount
// Stop
//
newAmount = FutureValue(amount,interestRate);
cout << "The new dollar amount is ", newAmount
return 0;
}
// num FutureValue(num initialAmount, num interestRate)
// Declarations
// num finalAmount
// finalAmount = (1 + interestRate/100) * initialAmount
// return finalAmount
int main()
{
int FutureValue(int initialAmount >> int interestRate);
int finalAmount;
finalAmount = (1+ interestRate/100) * initialAmount;
return final Amount;
system("PAUSE");
return 0;
}
int main( )
{
// Declarations
// num amount
// num newAmount
// num interestRate
int amount;
int newAmount;
int 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
cout << "Please enter dollar amount. " << endl;
cin >> amount;
cout << "Please enter the interest rate(e.g., nine percent should be entered as 0.9). " << endl;
cin >> interestRate;
// newAmount = FutureValue(amount,interestRate)
// output "The new dollar amount is ", newAmount
// Stop
//
newAmount = FutureValue(amount,interestRate);
cout << "The new dollar amount is ", newAmount
return 0;
}
// num FutureValue(num initialAmount, num interestRate)
// Declarations
// num finalAmount
// finalAmount = (1 + interestRate/100) * initialAmount
// return finalAmount
int main()
{
int FutureValue(int initialAmount >> int interestRate);
int finalAmount;
finalAmount = (1+ interestRate/100) * initialAmount;
return final Amount;
system("PAUSE");
return 0;
}
Did you try compiling it? A compiler will tell you your errors.
Line 36: No forward declarations for FutureValue.
Line 37: Improper use of , operator. No ;
Line 12, 47: Multiple declarations of main(). A program can have only one main().
Line 49: What is the >> operator supposed to be doing here? It's neither an input operation nor a shift operation. This whole statement is messed up.
Line 52: finalAmount misspelled (no space).
Line 53: This statement will never be executed.
PLEASE USE CODE TAGS (the <> formatting button) when posting code. http://v2.cplusplus.com/articles/jEywvCM9/
It makes it easier to read your code and it also makes it easier to respond to your post.
Hint: You can edit your previous post, highlight you code and press the <> formatting button.
Thank you. I tried to correct it to the best of my understanding... Im sorry im just new and dont know much... i do see the complier errors but they dont always make sense to me...here is what i tried to correct..
// Pseudocode PLD Chapter 9 #3 pg. 400
// Name: Liat Ledder
// Email: ledder.liat@titans.easternflorida.edu
// Purpose:
//
// Start
#include <iostream>
#include <cstdlib>
usingnamespace std;
int main( )
{
// Declarations
// num amount
// num newAmount
// num interestRate
int amount;
int newAmount;
int interestRate;
int futureValue;
// 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
cout << "Please enter dollar amount. " << endl;
cin >> amount;
cout << "Please enter the interest rate(e.g., nine percent should be entered as 0.9). " << endl;
cin >> interestRate;
// newAmount = futureValue(amount,interestRate)
// output "The new dollar amount is ", newAmount
// Stop
//
newAmount = futureValue(amount,interestRate);
cout << "The new dollar amount is " << newAmount;
return 0;
}
// num FutureValue(num initialAmount, num interestRate)
// Declarations
// num finalAmount
// finalAmount = (1 + interestRate/100) * initialAmount
// return finalAmount
int futureValue(int initialAmount, int interestRate);
int finalAmount;
finalAmount = (1+ interestRate/100) * initialAmount;
return finalAmount;
return 0;
You need to put curly braces for futureValue() and remove the semicolon like this:
1 2 3 4 5
int futureValue(int initialAmount, int interestRate) {
int finalAmount;
finalAmount = (1+ interestRate/100) * initialAmount;
return finalAmount;
}
And you will also need to define a prototype for futureValue() above the main() function like this: int futureValue(int initialAmount, int interestRate);
Edit: You also have a return 0; on the last line that needs to be removed.
int main( )
{
// Declarations
// num amount
// num newAmount
// num interestRate
int amount;
int newAmount;
int interestRate;
int futureValue;
// 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
cout << "Please enter dollar amount. " << endl;
cin >> amount;
cout << "Please enter the interest rate(e.g., nine percent should be entered as 0.9). " << endl;
cin >> interestRate;
// newAmount = futureValue(amount,interestRate)
// output "The new dollar amount is ", newAmount
// Stop
//
newAmount = futureValue(amount,interestRate);
cout << "The new dollar amount is " << newAmount;
return 0;
}
// num FutureValue(num initialAmount, num interestRate)
// Declarations
// num finalAmount
// finalAmount = (1 + interestRate/100) * initialAmount
// return finalAmount
int futureValue(int initialAmount, int interestRate)
{
int finalAmount;
finalAmount = (1+ interestRate/100) * initialAmount;
return finalAmount;
}
You need to create a function prototype above main for futerValue, or move the futureValue function above main.
Line 12 you have a variable name the same as your function name.
Line 15 tells you you would be inputting the interest rate with support for a decimal point yet your variable interestRate is assigned as a int. The same goes for amount and finalAmount, I would hazard a guess these also need to be a float.
FutureValue, would also need to return a floatand not an int.