Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
i supposed to use fucntion stub but i don't i did it right.. n it won't compile..
can someone tell me wats wrong with my program plz..// loan.cpp
// determine the maximum amount the customer can borrow#include <iostream>
#include <iomanip>using namespace std;
double amount(double p, double r, int m)
int main()
{
double payment, rate, loan_amount;
int months;cout << setiosflags(ios::fixed | ios::showpoint)
<< setprecision(2);cout << "Monthly payment: $ ";
cin >> payment;
cout << "Loan life time in months: ";
cin >> months;
cout << "Annual interest rate (%): ";
cin >> rate;
loan_amount = amount(payment, rate, months);
cout << "The amount of loan: $ " << loan_amount << endl;
return 0;
}double amount(double p, double r, int m)
{
double num, den;
num = 12*p - pow(12*p + r*p, -m);
den = r
loan_amount = num/den;
}

You're missing a semicolon proceeding your function declaration. Try adding that on, and report any other errors that you might have. The error reports would be extremely helpful to us.
- Rolos

is loan_amount in the right scope?
wouldn't it have to be a global variable for that or does it work fine as an equals. should work if a value is returned

loan_amount is in the scope of main and is not passed to this function, where it is used:
double amount(double p, double r, int m)
Therefore, you need to either have it as a global variable or pass it into the 'amount' function where it is used.
IR

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |