-1

hello there..! can somebody help me how to call this function...the program function will appear when i select the case no 3 at swich code... however there is an error appear...bytheway is it correct i using `"void loan_schedule ();"`

..to Generate loan payment schedule coding...when i choose number 3 at main menu...

```
#include <math.h> // pow()
#include <iostream.h>
#include <iomanip.h> // setprecision(), setw()
///////////////////////////////////////////
int show_menu();
void loan_schedule ();
///////////////////////////////////////////////////////////////
int show_menu()
{
int answer;
void ProcessInterestAmount();
cls();
cout<<endl<<endl;
cout<<"\t%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"<<endl;
cout<<"\t% A'LONG CAR LOAN FEATURES %" <<endl;
cout<<"\t%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"<<endl<<endl<<endl;
cout << "What kind of value do you want to estimate?";
cout << "\n1 - Calculate the monthly installment";
cout << "\n2 - To take loanEstimate the interest rate applied on a loan";
cout << "\n3 - To build laon schedule";
cout << "\n4 - Estimate the interest rate applied on a loan";
cout<<"\n5 - EXIT"<<endl<<endl;
cout<<"\t\tCHOOSE YOUR SELECTION :";
cin >> answer;
switch(answer)
{
case 1:
{ monthlyinstallament();
break;}
case 2:
{ totakeloan();
break;}
case 3:
{ loan_schedule();
break;}/*
case 4:
ProcessPrincipal();
break;
case 5:
ProcessPeriod();
break;*/
default:
cout << "\nInvalid Selection\n";
}
getch ();
return 0;
}
/////////////////////////////////////////////////////////
// Generate loan payment schedule
void loan_schedule(double principal,double interest_rate,double term_years,double compounding_periods_per_year);
int main(int argc,char *argv[])
{
double inprincipal, inrate, interms;
if (argc > 1)
inprincipal = atof(argv[1]);
else {
cout << endl << "Amount of loan:$";
cin >> inprincipal;
}
if ( inprincipal< 0.005) {
cout << "Bad loan amount!" << endl;
return 1;
}
if (argc > 2)
inrate = atof(argv[2]);
else {
cout << "Annual interest rate(%):";
cin >> inrate;
}
if ( inrate < 1) inrate *= 100;
if ( inrate< 1) {
cout << "Bad interest rate!" << endl;
return 1;
}
if (argc > 3)
interms = atof(argv[3]);
else {
cout << "Number of years:";
cin >> interms;
}
if ( interms< 0.005) {
cout << "Bad number of years!" << endl;
return 1;
}
loan_schedule( inprincipal, inrate, interms, 12);
return 0;
}
void loan_schedule(double principal,double interest_rate,double term_years,double compounding_periods_per_year)
{
double irate; // interest rate
double term; // number of compounding periods for life of loan
double paymt; // payment per compounding period.
int paymentnum; // number of payments
double balance; // running remaining principal to be paid
double totalpayment; // accumulated payments
double totalipaid; // accumulated interest paid
double totalppaid; // accumulated principal paid
// Generate header
cout << endl;
cout << "Loan Payback Schedule" << endl;
cout << "on $" << setprecision(2) << principal ;
cout << " at " << interest_rate << "%" ;
cout << " annually for " << term_years << " year(s)" << endl ;
if (fabs(compounding_periods_per_year - 1) > 0.0001) {
cout << "compounded " << compounding_periods_per_year;
cout << " times per year" << endl;
}
cout << endl;
cout << "PAYMENT # ";
cout << "BALANCE ";
cout << "PAYMENT ";
cout << "INTEREST PAID ";
cout << "PRINCIPAL PAID ";
cout << "REMAINING";
cout << endl << endl;
// Initialize variables for loop
irate = interest_rate/(100*compounding_periods_per_year);
term = term_years*compounding_periods_per_year;
paymt = ceil(100*principal*irate*pow(1+irate,term)
/(pow(1+irate,term)-1))
/100;
paymentnum = 0;
balance = principal;
totalpayment = 0;
totalipaid = 0;
totalppaid = 0;
cout.setf(ios::fixed | ios::showpoint);
cout.precision(2);
// Report each period's payment
while (balance>0.005) { // need to pay if more 1/2 cent outstanding
cout << setw(9) << ++paymentnum;
cout << setw(9) << balance;
if (paymt > balance*(1+irate))
paymt = ceil(100*balance*(1+irate)-0.5)/100;
cout << setw(9) << paymt;
totalpayment += paymt;
cout << setw(15) << balance*irate ;
totalipaid += balance*irate;
cout << setw(16) << (paymt-balance*irate);
totalppaid += paymt - balance*irate;
balance -= paymt - balance*irate;
cout << setw(11) << balance;
cout << endl;
}
// Summarize loan payments
cout << endl;
cout << "Total payments: " << paymentnum << endl;
cout << "Total paid: $" << setw(14) << totalpayment << endl;
cout << "Interest paid: $" << setw(14) << totalipaid << endl;
cout << "Principal paid: $" << setw(14) << totalppaid << endl;
}
error
C:\mydocuments.cpp(293) : error C2731: 'main' : function cannot be overloaded
```

*Edited 3 Years Ago by happygeek*: fixed formatting