Limit order

How can I limit order to 10?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
  void menu2()
{    
ofstream write;
write.open("order.txt");
if(!write)
{
	cout<<"file can not open"<<endl;
	exit (-1);
}
  	 a:
   	cout<<"\n\n\tENTER YOUR ORDER (one order at a time): "; 
    cin>>ch;
    
    
   switch(ch)
   {
   	case 1:
   		cout<<"\n\n\tHOW MANY order YOU WANT :";
   		cin>>order;
   		
   		total=total+(480*order);
   		write<<"YOU ORDER  Veggie Supreme : 480";
   		write<<" \n";
   		write<<"NUMBER OF order IS : "<<order;
   		write<<"\n";
   	cout<<"\n\n\n\tYOU ORDER  Veggie Supreme "<<endl<<"\tYOUR ORDER SUCCESSFULLY SAVED "<<endl;
   	break;
   	
   	case 2:
   		cout<<"\n\n\tHOW MANY order YOU WANT :";
   		cin>>order;
   		total=total+(440*order);
   		write<<"YOU ORDER  Exotica : 440";
   		write<<" \n";
   		write<<"NUMBER OF order IS : "<<order;
   		write<<"\n";
   	cout<<"\n\n\n\tYOU ORDER  Exotica "<<endl<<"\tYOUR ORDER SUCCESSFULLY SAVED "<<endl;
   	break;
   	
   	case 3:
   		cout<<"\n\n\tHOW MANY CHICKEN SIZZLER YOU WANT :";
   		cin>>order;
   		total=total+(580*order);
   			write<<"YOU ORDER  Chicken Sizzler : 580";
   			write<<" \n";
   			write<<"NUMBER OF Chicken Sizzler IS : "<<order;
   			write<<"\n";
   	cout<<"\n\n\n\tYOU ORDER  Chicken Sizzler "<<endl<<"\tYOUR ORDER SUCCESSFULLY SAVED "<<endl;
   	break;
   	
   	case 4:
   		cout<<"\n\n\tHOW MANY CHRISPY CHICKEN YOU WANT :";
   		cin>>order;
   		
   		total=total+(520*order);
   		write<<"YOU ORDER  Chrispy Chicken : 520\n";
   		write<<"NUMBER OF Chrispy Chicken IS : "<<order;
	   	cout<<"\n\n\n\tYOU ORDER  Chrispy Chicken "<<endl<<"\tYOUR ORDER SUCCESSFULLY SAVED "<<endl;
   	break;
   	
   	case 5:
   		cout<<"\n\n\tHOW MANY SPAGHETTI YOU WANT:";
   		cin>>order;
   		total=total+(350*order);
   		write<<"YOU ORDER  Spaghetti : 350";
   		write<<"NUMBER OF Spaghetti IS : "<<order;
   		write<<"\n";
   	cout<<"\n\n\n\tYOU ORDER  Spaghetti "<<endl<<"\tYOUR ORDER SUCCESSFULLY SAVED "<<endl;
   	break;
   	
   	case 6:
   		cout<<"\n\n\tHOW MANY order YOU WANT:";
   		cin>>order;

   		total=total+(400*order);
   		write<<"YOU ORDER Country Feast : 400";
   		write<<"\n ";
   			write<<"NUMBER OF order IS : "<<order;
   		write<<"\n";
   	cout<<"\n\n\n\tYOU ORDER Country Feast "<<endl<<"\tYOUR ORDER SUCCESSFULLY SAVED "<<endl;
   	break;
   	
   	case 7:
   		cout<<"\n\n\tHOW MANY TETRAZZINI YOU WANT:";
   		cin>>order;
   	
   		total=total+(420*order);
   		write<<"YOU ORDER Tetrazzini : 420";
   		write<<"\n ";
   			write<<"NUMBER OF Tetrazzini IS : "<<order;
   		write<<"\n";
   	cout<<"\n\n\n\tYOU ORDER  Tetrazzini "<<endl<<"\tYOUR ORDER SUCCESSFULLY SAVED "<<endl;
   	break;
   	
   	case 8:
   		cout<<"\n\n\tHOW MANY order YOU WANT :";
   		cin>>order;
   		total=total+(540*order);
   		write<<"YOU ORDER Double Cheese : 540";
   		write<<" \n";
   		write<<"NUMBER OF order IS : "<<order;
   		write<<"\n";
   	cout<<"\n\n\n\tYOU ORDER   Double Cheese "<<endl<<"\tYOUR ORDER SUCCESSFULLY SAVED "<<endl;
   	break;
   	
   	case 9:
   		cout<<"Proceed to checkout: ";
   		checkout();
   		break;
   		
   	case 10:
   		cout<<"\n\t\t\t\t\t Brought To You By code-projects.org";
   		exit(0);
   		break;
   	
   	default:
   		cout<<"\n\n\t\t\t\t\t\t\tYOU ENTER WRONG ORDER KEY !!!!! "<<endl;
   		break;
   }
   cout<<"\n\tDO YOU WANT ANOTHER ORDER (yes=1/no=0) :";
   cin>>yes;
   if(yes==1)
   {
   	goto a;
  
   }
   else
   write.close();
   checkout();
}
Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
int getOrder()
{
   const int orderMax = 10;
   int order = orderMax + 1;
   while ( order > orderMax )
   {
      cout << "How many would you like? ";
      cin >> order;
      if ( order > orderMax ) cout << "That's greedy; you'll get fat.\n\n";
   }
   return order;
}
It works but I also want to Include the quantity of overall order like for example I ordered 2 pizza and 2 burger then the overall order will be count as 4.
Last edited on
Topic archived. No new replies allowed.