saving input data and showing its total value in while loop

G

gaga

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 "<<pieAMOUNT<<" 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 :)
 
U

untitled

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 "<<pieAMOUNT<<" 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
 
J

John Harrison

gaga said:
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 "<<pieAMOUNT<<" 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;



}

The're called variables, and are a surprisingly difficult thing for some
people to grasp.

Here's a clue

pieTOTAL = pieTOTAL + pieAMOUNT;

john

john
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,050
Latest member
AngelS122

Latest Threads

Top