MR.chan l asked:


The program i make will determine how many monmths it will take to pay off that loan, what the final payment will be, and how much interest total I will have to pay. for example

** Welcome to the consumer loan calculator**
How much to do you want to borrow? 1000
What is the annual interest rate expressed as a percent? 18
What is the monthly payment amount? 50

ANSWER: Your debt will be paid off after 24 months, with a final payment of just 47.83. The total amount of interest you will pay during that time is 197.83.

Melvin

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