### help still confused

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)
You need a function called FutureValue(int amount, int interestRate).

 ``1234567`` ``````int FutureValue(int amount, int interestRate) { int Value = 0; return Value; };``````

oh is that the same on most of these or just the 2 future value parts or is it used to find final amount as well?
compiler flags this int Value = 0;
oh got it was a ; blasted things i hate them lol
I don't know if its the same, but just going by what you want.

The compiler flags it because its not used in your code. Its just been initialized.
// 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

 ``12345678910111213141516171819202122232425262728293031`` ``````#include #include using namespace std; int main(int argc, char *argv[]) { int amount, newAmount, interestRate; cout <<"Please enter the dollar amount."<> amount; cout <<"Please enter the interest rate(e.g., nine percet should be entered as 9.0). "<> 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.

 ``1234567`` ``````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:

 ``123456789101112131415`` ``````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."<> amount; ``````

You already have a function for FutureValue, you don't need to include the one I gave you.
Last edited on
 ``12345678910111213141516171819202122`` ``````using namespace 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."<> amount; cout <<"Please enter the interest rate(e.g., nine percet should be entered as 9.0). "<> 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.
Last edited on
Topic archived. No new replies allowed.