/*
*/
#include <iostream.h>
#include<iomanip.h>
void main(void) {
double initial_amount, interest_rate, monthly_payment, amount, final_payment;
int i, month;
const double initial amount=1000, interest rate= 12%, monthly payment=80;
cout << setiosflags (ios::fixed | ios::showpoint)<<setprecision(2);
for (;
{
cout << "Please enter amount and monthly_payment (0 0 to stop): ";
cin >> initial_amount >> payment;
if (initial_amount == 0 && amount == 0) {
break;
}
if (initial_amount <= 0) {
cout << "** Invalid inputs ignored **" << endl;
} else {
// output header
cout << endl << " Rate Months Total Paid " << endl;
// for each posible interest rate
for (i = 0; i < rows; i++) {
interestment += investment * (interest_rate/100.0);
// produce a row of the table
cout << setw(8) << setprecision(1) << rate;
// compute and output months and the total payment
amount = initial_amount; totalPayments = 0; months = 0;
for (;
{
// add another month's interest
interest *= 1 + (rate / (12 * 100));
months++;
if (debt < payment) {
// we've come to the last payment
totalPayments += amount;
cout << setw(8) << months << setw(12) << setprecision(2) << totalPayments;
break;
}
// make a regular payment
totalPayments += payment; debt -= payment;
if (debt >= initialDebt) { // we're going nowhere (the debt is growing)
cout << setw(8) << "**" << setw(12) << "****.**";
break;
}
rate = initialRate + (i * rateIncrement);
cout<<setw(8)<<"initial_amount"<<setw(8)<<"Interest_rate"
<<setw(8)<<"monthly_payment"<<setw(8)<<"final_payment"<<endl;
cout<<setiosflags(ios::fixed);<<setprecision(2);
for(i=0;i<=60;i++) {
cout<<setw(8)<<initial_amount<<setw(8)<<interest_rate<<setw(8)
<<monthly_payment<<setw(8)<<final_payment<<endl;
}
year=o;
while(investment<target){
interestment += investment * (interest_rate/100.0);
years++;
}