Computing.Net > Forums > Programming > c++ help

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

c++ help

Reply to Message Icon

Name: danny
Date: October 1, 2003 at 13:22:29 Pacific
OS: window xp pro
CPU/Ram: p4 2.4 / 1 GB
Comment:

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;
}




Sponsored Link
Ads by Google

Response Number 1
Name: Rolos
Date: October 1, 2003 at 17:15:45 Pacific
Reply:

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


0

Response Number 2
Name: moltar
Date: October 2, 2003 at 10:59:13 Pacific
Reply:

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


0

Response Number 3
Name: Infinite Recursion
Date: October 2, 2003 at 12:31:19 Pacific
Reply:

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



0

Response Number 4
Name: Rolos
Date: October 2, 2003 at 19:54:19 Pacific
Reply:

Yeah! That's right! Declare your function before main(). Sorry about that.

- Rolos


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: c++ help

Simple C Help!!! www.computing.net/answers/programming/simple-c-help/9795.html

C# help www.computing.net/answers/programming/c-help/3176.html

help help!!!..C...data file..please www.computing.net/answers/programming/help-helpcdata-fileplease/8092.html