-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMenu.cpp
More file actions
42 lines (35 loc) 路 895 Bytes
/
Copy pathMenu.cpp
File metadata and controls
42 lines (35 loc) 路 895 Bytes
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
#include <iostream>
void show_menu( std::string menu[],int size);
int main(){
bool check;
std::string user;
std::string menu[] = {"chips","bun","redbull"};
int size = sizeof(menu)/sizeof(menu[0]);
show_menu(menu,size);
do{
std::cout<<"Enter item to put in cart ( Q to quit) :";
std::getline(std::cin,user);
check =false;
if (user!="q" && user!="Q"){
for(int j = 0 ;j<size;j++){
if (user == menu[j]){
check = true;
break;
}
}
if(check== false){
std::cout<<"Invalid Item , Plz select the items from menu \n";
}
}
}while(user!="q" && user!="Q");
return 0;
}
void show_menu( std::string menu[],int size){
int in = 1;
std::cout<<"============== MENU ============== \n";
for (int i =0; i<size; i++){
std::cout<<in<<". "<<menu[i]<<'\n';
in++;
}
std::cout<<"================================== \n";
}