Need help with Mortgage Schedule

C++ Mortgage Schedule - Please help!!!

  • (2 Pages)
  • +
  • 1
  • 2

24 Replies - 2565 Views - Last Post: 18 September 2006 - 10:00 AM Rate Topic: -----

#1 promiscuoustx  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 36
  • Joined: 30-August 06

Need help with Mortgage Schedule

Posted 17 September 2006 - 05:26 PM

I am hoping someone can look at my code and figure out why it is not compiling. I am trying to run an amortization schedule, but it won't compile completely. It is probably something that I am overlooking... I am using Dev C++ for my compiler.

#include <iostream>		
#include <iomanip>
#include <cmath>	
#include <cctype>
#include <stdlib.h>
#include <sstream>	

using namespace std;

void MortSched(double, double, int);

//The structure below will contain the mortgage information

struct PaymentInfo
{
	   float fMonPayment;
	   float fYears;
	   float fInterestRate;
	   float fLoanAmount;
	   };
	   
int GetPayment();
int LoopAgain();
float UserInput();
void GetPaymentInfo(PaymentInfo& payinfo);
void DeterminePayment(PaymentInfo& payinfo);
void ShowPayment(PaymentInfo& payinfo);
char iResponse;

//The following section of code will validate user input.  We only want the user to
//be able to enter numbers or the decimal.

class nondigit
{
	  public:
			 bool operator() (char c)
			 {
				  if (c =='.')
				  {
						return !1;
						}
						else
						{
							return !isdigit(c);
							}
							}
							};
							
//This next section of code will accept the user input and validate all input
//the user enters.  The main function here is to validate all user input.

float UserInput()
{
	  float output;
	  string input;
	  cin >> input;
	  if (find_if(input.begin(), input.end(), nondigit()) == input.end())
	  {
								 stringstream mc(input);
								 mc >> output;
								 }
								 else
								 {
									 cout << input << " is not a valid number! Please try again!\n";
									 output = UserInput;
									 }
									 return output;
									 }
									 
//The next section of code prompts the user to enter the amounts for the mortgage calculator

void GetPaymentInfo(PaymentInfo& payinfo)
{
	 cout << "********************Mortgage Calculator********************\n";
	 cout << "What is the amount of the mortgage?  For example 200000\n";
	 payinfo.fLoanAmount = UserInput();
	 cout << "What is the amount of years the mortgage will be financed? For example 30\n";
	 payinfo.fYears = UserInput();
	 cout << "What is the interest rate? For example 5.75\n";
	 payinfo.fInterestRate = UserInput();
	 }
	 
//The following code calculates the monthly payment amount based on the users input

void DeterminePayment(PaymentInfo& payinfo)
{
	 payinfo.fMonPayment =
	 {
						 payinfo.fLoanAmount *
						 {
											 (payinfo.fInterestRate / 100) / 12 * pow((payinfo.fInterestRate / 100) / 12 + 1, (payinfo.fYears * 12)))
											 /
											 (pow((payinfo.fInterestRate / 100) / 12 + 1, (payinfo.fYears * 12))-1
											 }
											 }
											 };
											 }
											 
//The following code displays the payment amount based on the users input

void ShowPayment(PaymentInfo& payinfo)
{
	 cout << "Amount of mortgage = $\n" << payinfo.fLoanAmount <<;
	 cout << "Years financed = \n" << payinfo.fYears <<;
	 cout << "Interest Rate = \n" << payinfo.fInterestRate <<;
	 cout << "Monthly Payment Amount = $\n" << payinfo.MonPayment <<;
	 }
	 
//The next section will allow the user to run the program again or exit the program

int LoopAgain()
{
	int loop = 0;
	char mychar[7];
	cout << "To run this program again, please press 1, and then press enter.\n";
	cout << "To exit this program, please press 2, and then press enter.\n";
	cin >> ws;
	cin.getline(mychar,7);
	if (mychar[0] == '1')
	{
				  cout << "Thank you for choosing option 1.  This program will run again.\n";
				  run = 1;
				  }
				  else
				  {
					  cout << "Thank you for choosing option 2.  This program will now exit.\n";
					  run = 0;
					  }
					  return run;
					  }
					  
int runGetPayment()
{
	float fMonPayment = 0.00;
	PaymentInfo structPaymentInfo;
	GetPaymentInfo(structPaymentInfo);
	DeterminePayment(structPaymentInfo);
	ShowPayment(structPaymentInfo);
	int again = LoopAgain();
	return again;
}
	
//We will offer the user the option to view the amortization schedule

cout.setf(ios::showpoint | ios::fixed);
cout.precision(2);

cout << "Would you like to view the Amortization Schedule? Press Y or N.\n";
iResponse = getch();
if(iResponse == 'Y' || iResponse == 'y')
{
   MortSched(fLoanAmount, finterestRate, fYears);
			iResponse = '\n';   
			}
			else
			{   
				iResponse = '\n';
		}	
		cout << endl << "Would you like to run this again? Press Y or N. ";
		iResponse = getch();

	}while((iResponse == 'Y') || (iResponse == 'y'));

	return 0;
}
//The following code will calculate the amortization schedule.

void MortSched(double fLoanAmount, double fInterestRate, int fYears)
{
	double Balance, PaidInt, MonPayment, LoanAmount, Principle;
	int lineCount = 0;
	cout.setf(ios::left);
	MonPayment = calcPayment(&LoanAmount, &InterestRate, &Years);
	Balance = LoanAmount;	  
	for (int InstallNumber = 1; InstallNumber <= Years; ++InstallNumber)
	{
		if (lineCount == 0)
		{
			system("CLS");
			cout << "Payment		  Loan		  Principle		  Interest" << endl;
			cout << "No.			  Balance	   Payment			Payment" << endl;
			cout << "**********************************************************" << endl; 
		}

		PaidInt = Balance * (InterestRate / (12 * 100));
		LoanAmount = MonPayment - PaidInt;
		Principle = Balance - Principle;
		cout << setw(12) << InstallNumber
			 << setw(15) << Balance
			   << setw(15) << MonPayment
			 << setw(15) << PaidInt << endl;
		Balance = Principle;		
		if (lineCount==12)
		{
			system("pause");
			lineCount = 0;
					} 
				   		else
		{
			lineCount++;
		}
	}

	cout.unsetf(ios::left);
	return;
}


Thanks!!! You guys are the best!! :D

This post has been edited by promiscuoustx: 17 September 2006 - 05:48 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Need help with Mortgage Schedule

#2 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: Need help with Mortgage Schedule

Posted 17 September 2006 - 05:52 PM

What error are you receiving when you attempt to compile? By providing the exact error message, our members can more effectively debug the code.
Was This Post Helpful? 0
  • +
  • -

#3 promiscuoustx  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 36
  • Joined: 30-August 06

Re: Need help with Mortgage Schedule

Posted 17 September 2006 - 05:56 PM

View PostAmadeus, on 17 Sep, 2006 - 05:52 PM, said:

What error are you receiving when you attempt to compile? By providing the exact error message, our members can more effectively debug the code.


At line 79, it states cannot convert 'float()()' to 'float' in assignment. It sticks on this one.
Was This Post Helpful? 0
  • +
  • -

#4 Xing  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 19
  • View blog
  • Posts: 725
  • Joined: 22-July 06

Re: Need help with Mortgage Schedule

Posted 17 September 2006 - 06:36 PM

Two changes
#include <cstdlib>

and
output = UserInput();


Now indent your code properly if you want any further suggestion.
Was This Post Helpful? 0
  • +
  • -

#5 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: Need help with Mortgage Schedule

Posted 17 September 2006 - 06:39 PM

I assume you mean further suggestions from you, as there are likely many members willing to offer suggestions no matter what the indenting looks like.

Perhaps it may be more effective to describe proper indenting techniques and encourage newer programmers to employ them instead of making demands.
Was This Post Helpful? 0
  • +
  • -

#6 promiscuoustx  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 36
  • Joined: 30-August 06

Re: Need help with Mortgage Schedule

Posted 17 September 2006 - 06:50 PM

View PostXing, on 17 Sep, 2006 - 06:36 PM, said:

Two changes
#include <cstdlib>

and
output = UserInput();


Now indent your code properly if you want any further suggestion.


That did help, but I am unsure of what you mean to "indent my code properly."
I thought I had my code formatted correctly??

View PostAmadeus, on 17 Sep, 2006 - 06:39 PM, said:

I assume you mean further suggestions from you, as there are likely many members willing to offer suggestions no matter what the indenting looks like.

Perhaps it may be more effective to describe proper indenting techniques and encourage newer programmers to employ them instead of making demands.


Thanks Amadeus!! Is my code that bad to read? Can you offer any suggestions? The fixes that Xing offered worked, and of course, now I am
hung up further down the code. Now I am getting on line 103, expected expected primary expression before '{' token. I thought I had them all in there
correctly.....
Was This Post Helpful? 0
  • +
  • -

#7 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: Need help with Mortgage Schedule

Posted 17 September 2006 - 06:56 PM

There are a few major formatting styles that most c and C++ programmers use...there is a brief overview here:

http://blogs.msdn.co...1/24/51893.aspx

but you can get much more information by googling indent styles or coding styles.

For the record, I'm an Allman man myself.

As for the current error, it likely has to do with the code in your DeterminePayment function...I'm not near a compiler at the moment, but you appear to be using the { brace after an assignment operator...is there a reason for that?
Was This Post Helpful? 0
  • +
  • -

#8 Xing  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 19
  • View blog
  • Posts: 725
  • Joined: 22-July 06

Re: Need help with Mortgage Schedule

Posted 17 September 2006 - 06:57 PM

View PostAmadeus, on 18 Sep, 2006 - 07:09 AM, said:

I assume you mean further suggestions from you,

I guess you people have lot of time or you guys are very generous to read such unindented code.

View PostAmadeus, on 18 Sep, 2006 - 07:09 AM, said:

as there are likely many members willing to offer suggestions no matter what the indenting looks like.

Good for the OP.

View PostAmadeus, on 18 Sep, 2006 - 07:09 AM, said:

Perhaps it may be more effective to describe proper indenting techniques and encourage newer programmers to employ them instead of making demands.

Sure...this will give OP a start

Formatting
Was This Post Helpful? 0
  • +
  • -

#9 promiscuoustx  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 36
  • Joined: 30-August 06

Re: Need help with Mortgage Schedule

Posted 17 September 2006 - 06:58 PM

View PostAmadeus, on 17 Sep, 2006 - 06:56 PM, said:

There are a few major formatting styles that most c and C++ programmers use...there is a brief overview here:

http://blogs.msdn.co...1/24/51893.aspx

but you can get much more information by googling indent styles or coding styles.

For the record, I'm an Allman man myself.


Thanks for the tips!! I have moved past that part, but now I am stuck on line 112. It says
expected declaration before '}' token....I will work on my formatting right now...
Was This Post Helpful? 0
  • +
  • -

#10 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: Need help with Mortgage Schedule

Posted 17 September 2006 - 06:59 PM

See my note above.
Was This Post Helpful? 0
  • +
  • -

#11 promiscuoustx  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 36
  • Joined: 30-August 06

Re: Need help with Mortgage Schedule

Posted 17 September 2006 - 07:07 PM

View PostAmadeus, on 17 Sep, 2006 - 06:59 PM, said:

See my note above.


What note above? About the formatting? I am working on it right now. Thanks!!
Was This Post Helpful? 0
  • +
  • -

#12 promiscuoustx  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 36
  • Joined: 30-August 06

Re: Need help with Mortgage Schedule

Posted 17 September 2006 - 07:20 PM

View Postpromiscuoustx, on 17 Sep, 2006 - 07:07 PM, said:

View PostAmadeus, on 17 Sep, 2006 - 06:59 PM, said:

See my note above.


What note above? About the formatting? I am working on it right now. Thanks!!


DUH!!! I am a blonde having a blonde moment!! Got past that!! I am almost there!! I have one more sticker point that I have tried to make adjustments to. I will add my corrected code below:
#include <iostream>		
#include <iomanip>
#include <cmath>	
#include <cctype>
#include <stdlib.h>
#include <sstream>	
#include <cstdlib>

using namespace std;

void MortSched(double, double, int);

//The structure below will contain the mortgage information

struct PaymentInfo
{
	   float fMonPayment;
	   float fYears;
	   float fInterestRate;
	   float fLoanAmount;
	   };
	   
int GetPayment();
int LoopAgain();
float UserInput();
void GetPaymentInfo(PaymentInfo& payinfo);
void DeterminePayment(PaymentInfo& payinfo);
void ShowPayment(PaymentInfo& payinfo);
char iResponse;

//The following section of code will validate user input.  We only want the user to
//be able to enter numbers or the decimal.

class nondigit
{
	  public:
			 bool operator() (char c)
			 {
				  if (c =='.')
				  {
						return !1;
						}
						else
						{
							return !isdigit(c);
							}
							}
							};
							
//This next section of code will accept the user input and validate all input
//the user enters.  The main function here is to validate all user input.

float UserInput()
{
	  float output;
	  string input;
	  cin >> input;
	  if (find_if(input.begin(), input.end(), nondigit()) == input.end())
	  {
								 stringstream mc(input);
								 mc >> output;
								 }
								 else
								 {
									 cout << input << " is not a valid number! Please try again!\n";
									 output = UserInput();
									 }
									 return output;
									 }
									 
//The next section of code prompts the user to enter the amounts for the mortgage calculator

void GetPaymentInfo(PaymentInfo& payinfo)
{
	 cout << "********************Mortgage Calculator********************\n";
	 cout << "What is the amount of the mortgage?  For example 200000\n";
	 payinfo.fLoanAmount = UserInput();
	 cout << "What is the amount of years the mortgage will be financed? For example 30\n";
	 payinfo.fYears = UserInput();
	 cout << "What is the interest rate? For example 5.75\n";
	 payinfo.fInterestRate = UserInput();
	 }
	 
//The following code calculates the monthly payment amount based on the users input

void DeterminePayment(PaymentInfo& payinfo)
{
	 payinfo.fMonPayment = (0);
	 {
						 payinfo.fLoanAmount = (0);
						 {
											 ((payinfo.fInterestRate / 100) / 12 * pow((payinfo.fInterestRate / 100) / 12 + 1, (payinfo.fYears * 12)))
											 /
											 (pow((payinfo.fInterestRate / 100) / 12 + 1, (payinfo.fYears * 12))-1);
						 }
	  }
}									   
											 
//The following code displays the payment amount based on the users input

void ShowPayment(PaymentInfo& payinfo)
{
	 cout << "Amount of mortgage = $\n" << payinfo.fLoanAmount << endl;
	 cout << "Years financed = \n" << payinfo.fYears << endl;
	 cout << "Interest Rate = \n" << payinfo.fInterestRate << endl;
	 cout << "Monthly Payment Amount = $\n" << payinfo.fMonPayment << endl;
	 }
	 
//The next section will allow the user to run the program again or exit the program

int LoopAgain();
int run()
{
	int loop = 0;
	char mychar[7];
	cout << "To run this program again, please press 1, and then press enter.\n";
	cout << "To exit this program, please press 2, and then press enter.\n";
	cin >> ws;
	cin.getline(mychar,7);
	if (mychar[0] == '1')
	{
				  cout << "Thank you for choosing option 1.  This program will run again.\n";
				  run = 1;
	}
				  else
				  {
					  cout << "Thank you for choosing option 2.  This program will now exit.\n";
					  run = 0;
				  }
					  return run;
}
					  
int runGetPayment()
{
	float fMonPayment = 0.00;
	PaymentInfo structPaymentInfo;
	GetPaymentInfo(structPaymentInfo);
	DeterminePayment(structPaymentInfo);
	ShowPayment(structPaymentInfo);
	int again = LoopAgain();
	return again;
}
	
//We will offer the user the option to view the amortization schedule

cout.setf(ios::showpoint | ios::fixed);
cout.precision(2);

cout << "Would you like to view the Amortization Schedule? Press Y or N.\n";
iResponse = getch();
if(iResponse == 'Y' || iResponse == 'y')
{
   MortSched(fLoanAmount, finterestRate, fYears);
			iResponse = '\n';   
			}
			else
			{   
				iResponse = '\n';
		}	
		cout << endl << "Would you like to run this again? Press Y or N. ";
		iResponse = getch();

	}while((iResponse == 'Y') || (iResponse == 'y'));

	return 0;
}
//The following code will calculate the amortization schedule.

void MortSched(double fLoanAmount, double fInterestRate, int fYears)
{
	double Balance, PaidInt, MonPayment, LoanAmount, Principle;
	int lineCount = 0;
	cout.setf(ios::left);
	MonPayment = calcPayment(&LoanAmount, &InterestRate, &Years);
	Balance = LoanAmount;	  
	for (int InstallNumber = 1; InstallNumber <= Years; ++InstallNumber)
	{
		if (lineCount == 0)
		{
			system("CLS");
			cout << "Payment		  Loan		  Principle		  Interest" << endl;
			cout << "No.			  Balance	   Payment			Payment" << endl;
			cout << "**********************************************************" << endl; 
		}

		PaidInt = Balance * (InterestRate / (12 * 100));
		LoanAmount = MonPayment - PaidInt;
		Principle = Balance - Principle;
		cout << setw(12) << InstallNumber
			 << setw(15) << Balance
			   << setw(15) << MonPayment
			 << setw(15) << PaidInt << endl;
		Balance = Principle;		
		if (lineCount==12)
		{
			system("pause");
			lineCount = 0;
					} 
				   		else
		{
			lineCount++;
		}
	}

	cout.unsetf(ios::left);
	return;
}


It comes to line 137 and states assignment of function 'int run()'
cannot convert 'int' to 'int()()' in assignment. I am still fixing the formatting also.
Was This Post Helpful? 0
  • +
  • -

#13 Xing  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 19
  • View blog
  • Posts: 725
  • Joined: 22-July 06

Re: Need help with Mortgage Schedule

Posted 17 September 2006 - 08:11 PM

Remember run() is a function. This is the problem run = 1;
What do you basically want to do? Do you want recursive function?
Was This Post Helpful? 0
  • +
  • -

#14 promiscuoustx  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 36
  • Joined: 30-August 06

Re: Need help with Mortgage Schedule

Posted 18 September 2006 - 06:00 AM

View PostXing, on 17 Sep, 2006 - 08:11 PM, said:

Remember run() is a function. This is the problem run = 1;
What do you basically want to do? Do you want recursive function?

Ok, I am finally getting to the end of this program....but it is stuck again on lines 160
and 161. The lines are
cout.setf(ios::showpoint | ios::fixed);
cout.precision(2);


I used this from an example program, so I am not really sure what to do with
this set of code and the error received. It says expected constructor, destructor,
or type conversion before '.' token. expected ',' or ';' before '.' token..... Here is my updated
and hopefully formatted correctly code:
#include <iostream>		
#include <iomanip>
#include <cmath>	
#include <cctype>
#include <stdlib.h>
#include <sstream>	
#include <cstdlib>

using namespace std;

void MortSched(double, double, int);

//The structure below will contain the mortgage information

struct PaymentInfo
{
	   float fMonPayment;
	   float fYears;
	   float fInterestRate;
	   float fLoanAmount;
};
	   
int GetPayment();
int LoopAgain();
float UserInput();
void GetPaymentInfo(PaymentInfo& payinfo);
void DeterminePayment(PaymentInfo& payinfo);
void ShowPayment(PaymentInfo& payinfo);
char iResponse;

//The following section of code will validate user input.  We only want the user to
//be able to enter numbers or the decimal.

class nondigit
{
	  public:
			 bool operator() (char c)
			 {
				  if (c =='.')
				  {
						return !1;
				  }
						else
						{
							return !isdigit(c);
						}
			 }
};
							
//This next section of code will accept the user input and validate all input
//the user enters.  The main function here is to validate all user input.

float UserInput()
{
	  float output;
	  string input;
	  cin >> input;
	  if (find_if(input.begin(), input.end(), nondigit()) == input.end())
	  {
								 stringstream mc(input);
								 mc >> output;
	  }
								 else
								 {
									 cout << input << " is not a valid number! Please try again!\n";
									 output = UserInput();
								  }
									 return output;
}
									 
//The next section of code prompts the user to enter the amounts for the mortgage calculator

void GetPaymentInfo(PaymentInfo& payinfo)
{
	 cout << "********************Mortgage Calculator********************\n";
	 cout << "What is the amount of the mortgage?  For example 200000\n";
	 payinfo.fLoanAmount = UserInput();
	 cout << "What is the amount of years the mortgage will be financed? For example 30\n";
	 payinfo.fYears = UserInput();
	 cout << "What is the interest rate? For example 5.75\n";
	 payinfo.fInterestRate = UserInput();
}
	 
//The following code calculates the monthly payment amount based on the users input

void DeterminePayment(PaymentInfo& payinfo)
{
	 payinfo.fMonPayment = (0);
	 {
						 payinfo.fLoanAmount = (0);
						 {
											 ((payinfo.fInterestRate / 100) / 12 * pow((payinfo.fInterestRate / 100) / 12 + 1, (payinfo.fYears * 12)))
											 /
											 (pow((payinfo.fInterestRate / 100) / 12 + 1, (payinfo.fYears * 12))-1);
						 }
	  }
}									   
											 
//The following code displays the payment amount based on the users input

void ShowPayment(PaymentInfo& payinfo)
{
	 cout << "Amount of mortgage = $\n" << payinfo.fLoanAmount << endl;
	 cout << "Years financed = \n" << payinfo.fYears << endl;
	 cout << "Interest Rate = \n" << payinfo.fInterestRate << endl;
	 cout << "Monthly Payment Amount = $\n" << payinfo.fMonPayment << endl;
}
	 
//The next section will allow the user to run the program again or exit the program

int LoopAgain()
{
	int run = 0;
	int loop = 0;
	char mychar[7];
	cout << "To run this program again, please press 1, and then press enter.\n";
	cout << "To exit this program, please press 2, and then press enter.\n";
	cin >> ws;
	cin.getline(mychar,7);
	if (mychar[0] == '1')
	{
				  cout << "Thank you for choosing option 1.  This program will run again.\n";
				  run = 1;
	}
				  else
				  {
					  cout << "Thank you for choosing option 2.  This program will now exit.\n";
					  run = 0;
				  }
					  return run;
}
					  
int runGetPayment()
{
	float fMonPayment = 0.00;
	PaymentInfo structPaymentInfo;
	GetPaymentInfo(structPaymentInfo);
	DeterminePayment(structPaymentInfo);
	ShowPayment(structPaymentInfo);
	int again = LoopAgain();
	return again;
}
	
//We will offer the user the option to view the amortization schedule

cout.setf(ios::showpoint | ios::fixed);
cout.precision(2);
cout << "Would you like to view the Amortization Schedule? Press Y or N.\n";
iResponse = getch();
if(iResponse == 'Y' || iResponse == 'y')
{
   MortSched(fLoanAmount, finterestRate, fYears);
			iResponse = '\n';   
}
			else
			{   
				iResponse = '\n';
			}	  
		cout << endl << "Would you like to run this again? Press Y or N. ";
		iResponse = getch();

}
	while((iResponse == 'Y') || (iResponse == 'y'));

	return 0;
}
//The following code will calculate the amortization schedule.

void MortSched(double fLoanAmount, double fInterestRate, int fYears)
{
	double Balance, PaidInt, MonPayment, LoanAmount, Principle;
	int lineCount = 0;
	cout.setf(ios::left);
	MonPayment = calcPayment(&LoanAmount, &InterestRate, &Years);
	Balance = LoanAmount;	  
	for (int InstallNumber = 1; InstallNumber <= Years; ++InstallNumber)
	{
		if (lineCount == 0)
		{
			system("CLS");
			cout << "Payment		  Loan		  Principle		  Interest" << endl;
			cout << "No.			  Balance	   Payment			Payment" << endl;
			cout << "**********************************************************" << endl; 
		}

		PaidInt = Balance * (InterestRate / (12 * 100));
		LoanAmount = MonPayment - PaidInt;
		Principle = Balance - Principle;
		cout << setw(12) << InstallNumber
			 << setw(15) << Balance
			   << setw(15) << MonPayment
			 << setw(15) << PaidInt << endl;
		Balance = Principle;		
		if (lineCount==12)
		   {
			system("pause");
			lineCount = 0;
 		   } 
				   		else
		{
			lineCount++;
   }
}

	cout.unsetf(ios::left);
	return;
}

Was This Post Helpful? 0
  • +
  • -

#15 Xing  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 19
  • View blog
  • Posts: 725
  • Joined: 22-July 06

Re: Need help with Mortgage Schedule

Posted 18 September 2006 - 06:16 AM

You are missing main() function.

This post has been edited by Xing: 18 September 2006 - 06:17 AM

Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2