Well title says it all, everytime i execute this program i get a MASSIVE number (like 4.95066e-324) , i dont know where im going wrong. please take a look at my code and pseudocode that was provided for me.
// 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 beentered 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
oh my goodness im dumb haha, how would i go about doing that? declaring it ? or just switching it out for finalamount? my instructor wrote the psuedocode and it just doesnt seem right.
L18 is a function declaration (prototype). These are usually placed after any #includes not in the middle of code. I suspect you mean to call the function here as per the appropriate comment.
We can look at you code and ask: where are 'newamount'? Only on lines 11 and 19:
1 2
double newamount;
cout << "The new dollar amount is " << newamount;
The first is a declaration, but it does include initializer. Here are examples of initialization:
1 2 3
double newamount {}; // sets value to 0.0
double newamount {3.14}; // sets value to 3.14
double newamount = FutureValue(amount,interestRate); // sets value to whatever the FutureValue returns
Your second line reads the current value of 'newamount'. Alas, the value was never set.
@keskiverto - I took your words to mean that double newamount; is a declaration and also an initializer which, of course, isn't right as there's no initializer. I see now that you meant that initializer was optional. Sorry :)