I am working on an assignment where I have to allow end-users to enter in data and to have C++ make a calculation. From there I have to set up a loop to allow users to go back and enter new data or just quit. I have the part down where the users are entering in information to get a calculation, but I am not understanding the part about looping to go back, any direction will be greatly appreciated. Here is my code for now:
//************************************************** *****
//Program: Calculations Payments
//Purpose: To calculate a mortgage monthly payment by the user entering input
// and to allow the user to enter new data if they wish or to just quit the program.
//Programmer: Cameron Faldeti
//Date: 10/30/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
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 calcuating the monthly payment
double InterestRate; //Interest Rate in percentage used for the loan amount
double MortgageMonthlyPayment;
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 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); //Calculates the monthly mortgage payment
cout << "Mortgage monthly payment is: $ " << MortgageMonthlyPayment << endl;
//Allow user to loop back and enter new data or to just quit the program
while (letter != 'Q' && letter != 'Z')
return 0; //End of program
}