By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,261 Members | 1,325 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,261 IT Pros & Developers. It's quick & easy.

Using Lists In C++

P: 10
I am currently writing a C++ program that has to calculate and display the monthly mortgage payment amount using the amout of the mortgage, the term, and interest rate as input by the user. Next, I have to list the loan balance and interest paid for each payment over the term of the loan. On terms that are longer, the list may scroll off, I have to set the program that will not allow users to scroll off but instead display a partial list and allow the user to continue the list. I have to allow the user to loop back and enter new data or just quit. I have part of my code set up, I am just stuck on lists, so any direction will be greatly appreciated.
//************************************************** *****
//Program: Calculations Payments
//Purpose: To calculate a mortgage monthly payment by the user entering input
// and to to list the loan balance as well as the interest paid for each payment over the term of the loan.
// In addition, this program will allow the user to enter new data if they wish or to just quit the program.
//Programmer: Cameron Faldeti
//Date: 11/06/06
//School: University of Phoenix
//Class: POS 440: Introduction To C++
//Instructor: John Williams
#include <iostream>
#include <iomanip>
#include <cmath> //Header file in order for a user to calculate math formulas
#include <list> //C++ header file used for creating and storing items in lists
using namespace std;
int main()

//Variable declarations
double LoanAmount; //Loan amount entered by the user in order to calculate a mortgage monthly payment
int term; //Years entered by user to use for calculating the monthly payment
double InterestRate; //Interest Rate in percentage used for the loan amount
double MortgageMonthlyPayment;
char quit;//Allows users to quit the program if they wish
quit = 'N'; //If users enter N, they will have the option to enter new data
quit = 'n'; //If users enter n, they will have the option to enter new data
//Allow user to loop back and enter new data or to just quit the program
cout << "Enter a loan amount: ";
cin >> LoanAmount;
cout << "Loan amount is: $ " << LoanAmount << endl;
cout << "Enter Interest rate: ";
cin >> InterestRate;
cout << "Interest rate is: " << right << setw(8) <<InterestRate << "%" << endl << endl;
cout << "Enter term: ";
cin >> term; //Total years for paying off a mortgage loan
cout << "Your term is: " << right << setw(2) << term << " years" << endl << endl;
//Mortgage monthly calculation
MortgageMonthlyPayment = (LoanAmount* pow((1+ InterestRate/100/12),term*12)* InterestRate/100/12)/((pow((1+InterestRate/100/12),term*12))-1);
cout << "Mortgage monthly payment is: $ " << MortgageMonthlyPayment << endl;
list<balance> LoanBalance; //list loan balance
list<balance> InterestPaid; //list of interest paid over loan term

cout << "Press N if you want to enter new data, or press 1 or press 2 to quit the program." << "Choice is: " << endl; //Gives users a chance to continue or quit
cin >> quit;
}while(quit!= '1'&& quit != '2');
return 0; //End of program
Nov 7 '06 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.