C++ Mtge Calculator

This is a discussion on C++ Mtge Calculator within the C++ Programming forums, part of the General Programming Boards category; Hi, I need to create a mortgage calculator program that asks the user to input the loan amount, mortgage term, ...

  1. #1
    Registered User
    Join Date
    Mar 2005
    Posts
    1

    C++ Mtge Calculator

    Hi,

    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?


    Code:
    #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
    
    	do
    	{
                                   //output message asking for loan amt
    		cout<<"Input the total loan amount:\n";
    
    		//input data
    		cin>>LOAN_AMOUNT;
    
    		//output message asking for interest rate
    		cout<<"Input the annual interest rate:\n";
    
    		//input data
    		cin>>INT_RATE;
    
    		//output message asking for term in years of loan
    		cout<<"Input the length of the loan in years:\n";
    
    		//input data
    		cin>>TERM_YEARS;
    
    
    		//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
    		payment=(LOAN_AMOUNT*
    			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
    			<<"\n";
    		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";
    		cout<<"\n";
    		cout<<"$" 
    			<<payment
    			<<" a month\n";
    		cout<<"\n";
    		cout<<"Payment Number\tLoan Balance\tInterest Paid\n";
    		cout<<"--------------\t------------\t-------------\n";
    
    		for (int paymentNumber=1; paymentNumber< ? ; ++paymentNumber)
    		{
    			cout<<paymentNumber<<'\n';
    		
    			
    		}
    
    		
    		//user can continue in a loop or quit
    			//output
    			cout<<"\n";
    			cout<<"Enter C to continue, Q to quit >";
    
    			//user input
    			cin>>quit;
    			cout<<"\n";
    
    		while((quit!='q') && (quit!='Q') &&
    
    			(quit !='c') && (quit !='C'));
    	}
    
    
    		while((quit!='q') && (quit!='Q'));
    
    		cout<<"Thanks for visiting\n";
    		
    }

  2. #2
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,801
    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.
    Woop?

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, 03: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, 09:48 AM
  5. Replies: 2
    Last Post: 05-10-2002, 04:16 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21