473,396 Members | 1,990 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Loops to Allow users to go back and enter new data or just quit

10
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
}
Nov 1 '06 #1
1 1153
teddarr
143 100+
try this:

#include <iostream>
#include <iomanip>
#include <cmath> //Header file in order for a user to calculate math formulas


using namespace std;

//******************************main()************** **********************
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;

char repeat = 'y';
while (repeat == 'y' || repeat == 'Y')
{

cout << "Enter a loan amount: ";
-
-
- Body of your program
-
-
-
cout << "Mortgage monthly payment is: $ " << MortgageMonthlyPayment << endl;

//Allow user to loop back and enter new data or to just quit the program
cout<<"would you like to enter another set of data: (y/n)"<<endl;
cin>>repeat;
}


return 0; //End of program
}
Nov 1 '06 #2

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

Similar topics

2
by: Fran Tirimo | last post by:
I am developing a small website using ASP scripts to format data retrieved from an Access database. It will run on a Windows 2003 server supporting FrontPage extensions 2002 hosted by the company...
1
by: Roderick Thomas | last post by:
This problem centers around the basic character/line count problem most people have asked and have received numerous responses to. However, my question is a little more detailed and I'm hoping...
12
by: Berj | last post by:
i have a novice question. is Access multi-user? can multiple users access the same database?
1
by: sige0008 | last post by:
Hi folks: I have figured out how to sacle glyph by one scalar array, and color by another scalar array. but when I want to change color by third scalar array, I met some problems. At the...
5
by: cameron | last post by:
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...
2
by: shblack | last post by:
I need help with a program I am writing for school. The program has to do the following: /* 1. Character string must be a minimium of 15 charactors. 2. If not 15 characters long it must give...
16
by: simpleeshelbee | last post by:
Hey all, This is my first post. I am really hoping that someone out there has a solution to my C++ coding problem... This is my code and what I have to do... I think it is rows of 1 - 10 and...
6
by: jackj | last post by:
Hi, I am first time C++ student and doing the usual tasks. This one is to create a triangle based on user input of how large (how many rows) and what symbol to use. I have managed to create a...
7
by: Osiris | last post by:
Just something I would like to share: I just learned the hard way (2 days detective work on a bug) that foreach loops are not at all like for loops, not intuitive at all. BEWARE: arrays and...
8
by: Nathan Sokalski | last post by:
I have several nested For loops, as follows: For a As Integer = 0 To 255 For b As Integer = 0 To 255 For c As Integer = 0 To 255 If <Boolean ExpressionThen <My CodeElse Exit For Next If Not...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.