NazoGirl asked:


include
#include
using namespace std;

const int month = 12;

void getInput(double&, double&, double&);
double payLoan(double, double, double, double, double&);

int main()
{
double balance,
interestRate,
monthlyPayment,
monthlyInterest,
totalInterest;

cout << "** Welcome to the Consumer Loan Calculator **";

getInput(balance, interestRate, monthlyPayment);
payLoan(balance, interestRate, monthlyPayment, monthlyInterest, totalInterest);

cout << "** Don't get overwhelmed with debt! **";

return 0;
}

//****************************************************
// This function asks the user to input the *
// principal, interest, and payment amount. *
// It only accepts positive values. *
// All three parameters are reference variables *
// so that the function returns the overwritten *
// values of the arguments which are passed to it. *
//****************************************************

void getInput(double& balance, double& interestRate, double& monthlyPayment);
{
do
{
cout << "How much do you want to borrow?"
cin >> balance;
} while (balance <= 0)
cout << "You must enter a positive number!\n";

do
{
cout << "What is the annual interest rate expressed as a percent?"
cin >> interestRate;
} while (interestRate <= 0)
cout << "You must enter a positive number!\n";

do
{
cout << "What is the monthly payment amount?"
cin >> monthlyPayment;
} while (monthlyPayment <= 0)
cout << "You must enter a positive number!\n";
}

//************************************************
// This function uses a nested loop to calculate *
// the monthly interest and payments. *
// It also keep track and reminds the user *
// of the total months to clear the debt. *
//************************************************

double payLoan(double balance, double interestRate, double monthlyInterest, double monthlyPayment,
double& totalInterest);
{
double interest,
payment,
totalInterest,
finalPayment,
leastPayment;

// Set numeric output formatting.
cout << fixed << showpoint << setprecision(2);

monthlyInterest = interestRate / month;

int months=1;
while (months++)
{
while (balance > monthlyPayment)
{
interest = balance * monthlyInterest;
payment = monthlyPayment - interest
if (payment < 1)
{
leastPayment = interest + 1;
cout << "You must make payments of at least $" << leastPayment << endl;
cout << "Because your monthly interest is $" << interest << endl;
}
balance = balance - payment
totalInterest += interest
}
if (balance < monthlyPayment)
break;
}
finalPayment = balance + balance * interest;

cout << "Your debt will be paid off after " << months << "months, ";
cout << "with a final payment of just $" << finalPayment << endl;
cout << "The total amount of interest you will pay during that time is $" << totalInterest << endl;
}
==================4 errors detected:============
C:\Documents and Settings\Administrator\My Documents\HW\2008fall\11.cpp:51: error: expected unqualified-id before '{' token
C:\Documents and Settings\Administrator\My Documents\HW\2008fall\11.cpp:51: error: expected `,' or `;' before '{' token
C:\Documents and Settings\Administrator\My Documents\HW\2008fall\11.cpp:84: error: expected unqualified-id before '{' token
C:\Documents and Settings\Administrator\My Documents\HW\2008fall\11.cpp:84: error: expected `,' or `;' before '{' token

This is a new compiler I've just downloaded and it's totally different from the UNIX HILL from school computers. I had put semicolons but I don't know why the compiler says a ";" is expected. I won't be able to use the school computers until next monday and this assignment is due tomorrow. could someone please compile this source file for me and tell me if there's any errors?(and how to fix them...)

Cheryl

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google

Comments

One Response to “C++-compilation problem?”

  1. Stephon M on July 13th, 2010 9:08 pm

    Jeremy

    Ok, you should really review your C++ syntax rules.

    1. You did not put semicolons after do-while loops.
    2. You put semicolons right after function names.
    3. You forgot to put semicolons at the end of cout statements.

    Here’s the error-free version of your code:

    #include
    #include
    using namespace std;

    const int month = 12;

    void getInput(double&, double&, double&);
    double payLoan(double, double, double, double, double&);

    int main()
    {
    double balance,
    interestRate,
    monthlyPayment,
    monthlyInterest,
    totalInterest;

    cout

Leave a Reply