|
From: <LO5...@ao...> - 2001-05-20 22:55:55
|
#include <iostream.h>
#include <stdlib.h>
const char a =3D 61;
const int SENNTINEL=3D -999;
const char SKIP =3D' ';
void main()
{
char choice;
int quantity;
int quit;
int cost;
int cost1;
int cost2;
int cost3;
int cost4;
int cost5;
int cost6;
int cost7;
int cost8;
int cost9;
int count =3D0 ;
int fbw=3D 61;
int fbb=3D 68;
int dp=3D 48;
int cc=3D358;
int crp=3D 98;
int cmp=3D159;
int pies=3D53;
int t1=3D92;
int t2=3D127;
int num;
cout << SKIP << "* * ******** The Bakery ************ * *" ;
cout << endl;
cout << endl;
cout << SKIP <<" Item code Item Price "=
;
cout << SKIP;
cout << endl;
cout << endl;
cout << SKIP <<" a Fresh Bread White 61p "=
;
cout << endl;
cout << SKIP <<" b Fresh Bread brown 68p "=
;
cout << endl;
cout << SKIP <<" c danish pastries 48p "=
;
cout << endl;
cout << SKIP <<" d celabration cake 358p "=
;
cout << endl;
cout << SKIP <<" e cookies regular pack 98p "=
;
cout << endl;
cout << SKIP <<" f cookies maxi pack 159p "=
;
cout << endl;
cout << SKIP <<" g pies 53p "=
;
cout << endl;
cout << SKIP <<" h sandwiches type 1 92p "=
;
cout << endl;
cout << SKIP <<" i sandwiches type 2 127p "=
;
cout << endl;
cout << endl;
cout << SKIP <<"******************************************************"=
;
cout << endl;
count =3D 0 ;
while (quit !=3D SENNTINEL)
{
cout << "please select an item" <<endl;
cin >> choice;
cout << "please select quantity press"<<endl;
cin >> num;
count=3D count + 1;
cout<< count;
if(choice=3D 'a')
{
cost1=3D fbw * num;
}
if(choice=3D 'b')
{
cost2=3D fbb * num;
}
if(choice=3D'c')
{
cost3=3D dp * num;
}
if(choice=3D'd')
{
cost4=3D cc * num;
}
if(choice=3D'e')
{
cost5=3D crp * num;
}
if(choice=3D'f')
{
cost6=3D cmp * num;
}
if(choice=3D'g')
{
cost7=3D pies* num;
}
if(choice=3D'h')
{
cost8=3D t1 * num;
}
else if(choice=3D'i')
{
cost8=3D t2 * num;
}
cout << endl;
cout << "press -999 to quit or 111 to continue"<<endl;
cin >> quit;
}
cout << SKIP << "* * ******** The Bakery ************ * *" ;
cout << endl;
cout << endl;
cout << SKIP <<" Item code Item Price Quantity =20
Price2 " ;
cout << SKIP <<" =20=
=20
";
cout << endl;
cout << endl;
cout << SKIP <<" a Fresh Bread White 61p" <<" "<< =20
num <<" "<<cost1;
cout << endl;
cout << SKIP <<" b Fresh Bread brown 68p" <<" "<< =20
num <<" "<<cost2;
cout << endl;
cout << SKIP <<" c danish pastries 48p" <<" "<< =20
num <<" "<<cost3;
cout << endl;
cout << SKIP <<" d celabration cake 358p" <<" "<< =20
num <<" "<<cost4;
cout << endl;
cout << SKIP <<" e cookies regular pack 98p" <<" "<< =20
num <<" "<<cost5;
cout << endl;
cout << SKIP <<" f cookies maxi pack 159p" <<" "<< =20
num <<" "<<cost6;
cout << endl;
cout << SKIP <<" g pies 53p" <<" "<< =20
num <<" "<<cost7;
cout << endl;
cout << SKIP <<" h sandwiches type 1 92p" <<" "<< =20
num <<" "<<cost8;
cout << endl;
cout << SKIP <<" i sandwiches type 2 127p" <<" "<< =20
num <<" "<<cost9;
cout << endl;
cout << endl;
cout << SKIP <<"******************************************************"=
;
cout << endl;
system("PAUSE");
return 0;
}
hello programmers i was wondering if anyone could help me with a problem , i=
=20
am trying to calculate num but i can only calculate the last num entered by=20
the user i want to calculate all num (numbers) that the user types in ie i=20
want num to be stored each time a different value for num is entered so that=
=20
i can calculate different quantities of items
eg, 10(num) * =A33.50
2(num) *61p
15(num) 89p
each time num is entered i only receive calculations for the last num entere=
d=20
15 in this example, but i need all nums to be calculated. The user can only=20
type in a code for an item eg a=3Dfresh brown bread followed by a quantity=20
(represented by num) this process is repeated until the user is happy with=20
there selection from the menu. I need to print out a menu indicating item ,=20
quantity , then cost which is item * quantity but i seem to only be able to=20
calculate the last num the user enters.
thanx for your precious time and patience in advance=20
from lostboyz.=20
|