473,625 Members | 2,999 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

saving input data and showing its total value in while loop

hi all,
i need to write a program - cash register for dummies, so to speak.
here's the gist - enter the amount of pies that a person wants to
get.
A person can get either, 1, 2, 3, or 4 pizza pies. At the end of the
day, the worker enters in -1 (negative 1), as the number of pies, to
indicate to the program that the program is done taking orders for
the
day. When the program is done taking orders, display the total number
of pies orders, and the amount of money the pies were in total.

what i have so far is:
#include <iostream>
using namespace std;
const int LOWER_LIMIT = 1;
const int UPPER_LIMIT = 4;
int main()
{
int pieAMOUNT;
cout<<"\t\t Greetings, fellow human!"<<endl<< endl;
while ((pieAMOUNT >= 0) & (pieAMOUNT != -1 )){
cout<< "Please enter amount between one and four that you
wish
to purchase: ";
cin>>pieAMOUNT;
if ((pieAMOUNT >= LOWER_LIMIT) & (pieAMOUNT <= UPPER_LIMIT))
{
cout<<"Total price for "<<pieAMOUN T<<" pizza pies is
$"<<pieAMOUNT*5 <<endl;
} else {
cout<<"You have entered a wrong amount!"<<endl;
}
}
if (pieAMOUNT = -1) {
cout<<"We are done taking orders for the day"<<endl;
}
return 0;

}
----------------------
i dont understand what features to use in order to save and store and
later find out the total of the pies/prices entered.
if you could give me some hints, i would be more than greatful!!

ps. yes it is a hw, but i dont need the code, i just need to know
which things to read more about and do it myself.
thanks :)

Mar 4 '07 #1
2 2026
On Mar 4, 3:21 am, "gaga" <baronessfrostb ...@gmail.comwr ote:
hi all,
i need to write a program - cash register for dummies, so to speak.
here's the gist - enter the amount of pies that a person wants to
get.
A person can get either, 1, 2, 3, or 4 pizza pies. At the end of the
day, the worker enters in -1 (negative 1), as the number of pies, to
indicate to the program that the program is done taking orders for
the
day. When the program is done taking orders, display the total number
of pies orders, and the amount of money the pies were in total.

what i have so far is:
#include <iostream>
using namespace std;
const int LOWER_LIMIT = 1;
const int UPPER_LIMIT = 4;
int main()
{
int pieAMOUNT;

cout<<"\t\t Greetings, fellow human!"<<endl<< endl;
while ((pieAMOUNT >= 0) & (pieAMOUNT != -1 )){
cout<< "Please enter amount between one and four that you
wish
to purchase: ";
cin>>pieAMOUNT;

if ((pieAMOUNT >= LOWER_LIMIT) & (pieAMOUNT <= UPPER_LIMIT))
{
cout<<"Total price for "<<pieAMOUN T<<" pizza pies is
$"<<pieAMOUNT*5 <<endl;
} else {
cout<<"You have entered a wrong amount!"<<endl;
}
}
if (pieAMOUNT = -1) {
cout<<"We are done taking orders for the day"<<endl;
}
return 0;

}

----------------------
i dont understand what features to use in order to save and store and
later find out the total of the pies/prices entered.
if you could give me some hints, i would be more than greatful!!

ps. yes it is a hw, but i dont need the code, i just need to know
which things to read more about and do it myself.

thanks :)
how about using files?

i posted "motion capture" today about 6 hours ago with source code, in
the last couple of lines you will see how to use files very simply for
output and in the beginning of the code you will find how to use it
for input, so simple.
and i recommend you see library documentation at cplusplus.com

Mar 4 '07 #2
gaga wrote:
hi all,
i need to write a program - cash register for dummies, so to speak.
here's the gist - enter the amount of pies that a person wants to
get.
A person can get either, 1, 2, 3, or 4 pizza pies. At the end of the
day, the worker enters in -1 (negative 1), as the number of pies, to
indicate to the program that the program is done taking orders for
the
day. When the program is done taking orders, display the total number
of pies orders, and the amount of money the pies were in total.

what i have so far is:
#include <iostream>
using namespace std;
const int LOWER_LIMIT = 1;
const int UPPER_LIMIT = 4;
int main()
{
int pieAMOUNT;
cout<<"\t\t Greetings, fellow human!"<<endl<< endl;
while ((pieAMOUNT >= 0) & (pieAMOUNT != -1 )){
cout<< "Please enter amount between one and four that you
wish
to purchase: ";
cin>>pieAMOUNT;
if ((pieAMOUNT >= LOWER_LIMIT) & (pieAMOUNT <= UPPER_LIMIT))
{
cout<<"Total price for "<<pieAMOUN T<<" pizza pies is
$"<<pieAMOUNT*5 <<endl;
} else {
cout<<"You have entered a wrong amount!"<<endl;
}
}
if (pieAMOUNT = -1) {
cout<<"We are done taking orders for the day"<<endl;
}
return 0;

}
----------------------
i dont understand what features to use in order to save and store and
later find out the total of the pies/prices entered.
if you could give me some hints, i would be more than greatful!!
The're called variables, and are a surprisingly difficult thing for some
people to grasp.

Here's a clue

pieTOTAL = pieTOTAL + pieAMOUNT;

john

john
Mar 4 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2505
by: Agnes | last post by:
I use while-loop the show the table content in web page. e.g (bookingno, booking date,customer no) However, the client need me insert one column (confirmdate ) and allow the user input and update the date . It seems very hard to do . Any one know how to do ? Thanks a lot Miss. Agnes Cheng
3
2275
by: Jeff | last post by:
Hello I need help with a problem I have homework for a larger program than shown below but the code below effectively shows the problem whem compiled and executed. Basically, I want to be able keep the loop going even if a character (alphabet) is entered when it should be a number i.e. the wrong data type is entered by mistake.
6
26249
by: obdict | last post by:
Hello, I used scanf() in a while loop, which ensures that user input is valid (must be an integer no greater than 21 or less than 3). If user enters a number out of the range, or enters non-number, he/she will be asked to retry. /* start */ int n;
4
1706
by: scota | last post by:
I am new to ASP.NET, C#. I have the following code which will not display the total Credits for all the records. It is printing "Total Credits: 0" instead of adding the credits. What am I missing? Credits is the 4th column in the datagrid and the 4th field in the SQL view. Credits data type is float. Thank you. protected void btnSubmit_Click(object sender, EventArgs e) {
4
2370
by: kelharis | last post by:
I am trying to write a program using a while loop, and a nested for loop inside. The program needs to run once, and then after completion, ask if the user would like to run the program again. The while statement needs to be true while the reply is "y" and must clear the buffer afterwards (i.e. must accept "yes", "youbetcha" etc. and clear the buffer after. ) Im stuck, the program is compiling, but returns to prompt when I run it. Here is the...
12
3221
by: beatjunkie27 | last post by:
I am working on a class assignment called Pennies for Pay the object of the program is to receive input for number of days worked. This should be > 0 and <= 40. An example output is below and you will notice, the pay doubles each day. Pay: $.01 on day 1. Total Salary $.01 Pay: $.02 on day 2. Total Salary $.03 Pay: $.04 on day 3. Total Salary $.07 Pay: $.08 on day 4. Total Salary $.15
1
2074
by: zelmila19 | last post by:
Hi can anyone tell me how to do this problem: Write a program using a while loop that asks the user to enter their sales for each month until they enter -1 (sentinel value). After this, it should tell the user how many months, the total sales and the average sales. If the user enters a negative value as the first input, it should not cause an error. The program should be able to produce the output below: Please enter your sales for month...
2
2432
by: nirav11 | last post by:
# include <iostream> # include <fstream> # include <iomanip> # include <cstdlib> // needed for exit () using namespace std; int main() { ifstream inFile; ofstream outFile;
2
14630
by: v13tn1g | last post by:
k += 1 total=0 while k <= 50: total += k * k the questions is below. when i input in this code and run it, it says that it is an infinite loop, i dont know what else to change.can someone help?
0
8692
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8354
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6116
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5570
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4089
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4192
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2621
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1802
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1499
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.