Thread: C++ Mtge Calculator

  1. #1
    Registered User
    Join Date
    Mar 2005

    C++ Mtge Calculator


    I need to create a mortgage calculator program that asks the user to input the loan amount, mortgage term, & interest rate. I am to display the mtge payment amount. I am fine with all of this.

    I am then to list the loan balance and interest paid for each pymt over the term of the loan. On longer-term loans, I am not to allow the list to scroll off the screen. I need to display a partial list and then allow the user to continue the list. This is where I am unsure of where to start. I began a for loop, but I don't know if this is in the right direction. I also can't find the formula for calculating the balance. Can anyone point me in the right direction to get started?

    #include <iostream> 
    #include <cmath> 
    #include <iomanip> 
    using namespace std; 
    int main()
    	float LOAN_AMOUNT=0; //loan amt
    	float INT_RATE=0; //interest rate
    	int TERM_YEARS=0; //loan term in years
    	char quit; //determines if user wants to quit
                                   //output message asking for loan amt
    		cout<<"Input the total loan amount:\n";
    		//input data
    		//output message asking for interest rate
    		cout<<"Input the annual interest rate:\n";
    		//input data
    		//output message asking for term in years of loan
    		cout<<"Input the length of the loan in years:\n";
    		//input data
    		//local variables
    		float RATE=INT_RATE/100; //rate in decimal format
    		float monthlyInterest; //monthly interest rate
    		int numberOfPayments; //total number of payments
    		float payment; //monthly payment
    		float balance; // loan balance
    		//calculate values
    		monthlyInterest=RATE/12; //monthly interest is rate/12
    		numberOfPayments=TERM_YEARS*12; //# of pymts is length of loan*12
    			pow(monthlyInterest + 1, numberOfPayments)
    			* monthlyInterest)/(pow(monthlyInterest + 1, 
    			numberOfPayments) - 1); //pow returns x raised to the power of y
    		//output results
    		cout<<fixed<<setprecision(2)//cout writes text to the screen
    		cout<<"Your monthly payment for "
    			<<TERM_YEARS <<" years\n";
    		cout<<"for an Interest Rate of "
    			<<INT_RATE <<"%\n"; 
    		cout<<"on a Loan Amount of $"
    			<<LOAN_AMOUNT <<":\n";
    			<<" a month\n";
    		cout<<"Payment Number\tLoan Balance\tInterest Paid\n";
    		for (int paymentNumber=1; paymentNumber< ? ; ++paymentNumber)
    		//user can continue in a loop or quit
    			cout<<"Enter C to continue, Q to quit >";
    			//user input
    		while((quit!='q') && (quit!='Q') &&
    			(quit !='c') && (quit !='C'));
    		while((quit!='q') && (quit!='Q'));
    		cout<<"Thanks for visiting\n";

  2. #2
    Join Date
    Aug 2002
    Tucson, Arizona
    Well there is no standard way for you to know how long the screen is. So what you could do is have a set amount of information to print but then it won't always work you would have to use a system specific method to figure out how big the screen is.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. I need help modifying my calculator!!
    By Matus in forum C Programming
    Replies: 5
    Last Post: 03-25-2008, 12:03 PM
  2. GUI Calculator - Critique
    By The Brain in forum Windows Programming
    Replies: 1
    Last Post: 02-25-2006, 04:39 AM
  3. Calculator + LinkedList
    By maro009 in forum C++ Programming
    Replies: 20
    Last Post: 05-17-2005, 12:56 PM
  4. Need help with calculator program
    By Kate in forum C# Programming
    Replies: 1
    Last Post: 01-16-2004, 10:48 AM
  5. Replies: 2
    Last Post: 05-10-2002, 04:16 PM