been at this last 3 days.. algorithm im stuck on ...
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
Ive read the tutorials perhaps im not comprehending how these things look completed i began to write this like this its wrong but based on the example im looking at in my book and online it matches the example unless this is for a different type of function i dont like functions im finding out..
int newAmount = int FutureValue(amount*interestRate);
its supposed to be for the part
newAmount = FutureValue(amount,interestRate)
// 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
#include <cstdlib>
#include <iostream>
usingnamespace std;
int main(int argc, char *argv[])
{
int amount, newAmount, 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;
int FutureValue(int amount, int interestRate);
int Value = 0;
return Value;
int FutureValue(int initialAmount, int interestRate);
int finalAmount
finalAmount =(1+ int interestRate/100)*initialAmount;
return finalAmount;
};
Thats what i got what am i doing wrong if you dont mind helping me figure out whats going wrong with it says last functions no good but program stops half way too i don't know what im doing wrong ;/
Functions are their own things. Because of this, they need to be opened and closed with brackets.
1 2 3 4 5 6 7
int FutureValue(int initialAmount, int interestRate) //this is a function
{ //<----open brace
int finalAmount
finalAmount =(1+ interestRate/100)*initialAmount; //type is already declared.
return finalAmount;
}// <---close brace
They also have to be placed outside of any other functions and before anything that uses them:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
int FutureValue(int initialAmount, int interestRate) //this is a function
{ //<----open brace
int finalAmount
finalAmount =(1+ interestRate/100)*initialAmount; //type is already declared in function header
return finalAmount;
}// <---close brace
int main(int argc, char *argv[])
{
int amount, newAmount, interestRate;
cout <<"Please enter the dollar amount."<<endl;
cin>> amount;
You already have a function for FutureValue, you don't need to include the one I gave you.
usingnamespace std;
int FutureValue(int initialAmount, int interestRate);
{
int finalAmount;
finalAmount =(1+ int inteestRate/100)*initiarlAmount;
return finalAmount;
}
int main(int argc, char *argv[])
{
int amount, newAmount, 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;
system("PAUSE");[code]
[/code]
still says 3 errors i had it go to 1 on the first time now 3 so they go before the main int makes sence cause it reads top down instructions right whats wrong with it do you see it?
on line 6 you are declaring an int called inteestRate as a right hand value (rvalue). This is not good syntax. I think you intended to use interestRate here.
On the same line you multiply the result by intiarlAmount, which i think is supposed to be initialAmount.
on line 3 you have a semicolon at the end of the line. You don't need that there.
Be careful on line 20, although its okay to do input float data into an integer, you will lose some decimal places.