This is the lab ive been assigned:
You want to buy a car but no one other than your parents will lend you any money. When you approach your father he agrees to loan you the money but only if he can charge you 6% simple interest on the outstanding balance. He requests that you create a C++ program that will do the calculations rather than using some pre-written. He also asks you to determine how many years you want the loan for.
In your analysis you decide that you will split the principle into equal parts and then add the interest for the month to the principle to determine the monthly payment. Then you can subtract the payment of the principle from the balance owed and recalculate the principle balance for the next payment.
You would like to find how much you will pay each month for the term of the loan. The output should look something like this
Enter the amount of the loan: 8000
Enter the number of years of the loan: 3
Payment Balance Principle Due Interest Due Total Due
1 8000 250 40 290
2 7750 250 38.75 288.75
3 7500 250 37.5 287.5
:
:
32 250 250 1.25 251.25
As an extra challenge keep track of the interest that is paid and display it at the end of the report.
What ive got so far is this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
#include <iostream>
using std::cout;
using std::endl;
using std::cin;
#include <iomanip>
using std::setprecision;
using std::setw;
int main()
{
double loan, months;
int years;
double intrate = .06;
double totdue, pbal, intdue;
double const pdue = 250;
double baldue;
int const mnthsinyr = 12;
double totalint;
cout << "Enter the amount of the loan: ";
cin >> loan;
cout << "Enter the number of years of the loan: ";
cin >> years;
cout << "Payment Balance" << setw(19)<< "Principle Due"<< setw(19)<<"Interest Due" << setw(19)<< "Total Due"<<endl;
months = mnthsinyr * years;
totalint = loan * intrate * years;
intdue= totalint / months;
totdue = pdue + intdue;
pbal = loan - totdue + intdue;
while (( loan < 32) && (intdue < 32) && (totdue < 32 ));
{
cout << setprecision(4);
cout << pbal <<setw(11)<< pdue << setw(19)<< intdue << setw(24)<< totdue;
}
return 0;
}
|
i know its wrong but im still working on it. this is my first semester in c++ so be gentle>=D. Thanks alot toanyone that helps.