Hi!, I’m still new to C++ and trying to build simple ordering system, I just need to find a way for the user to order more than 1 food, for example, after the user order the food, he/she will be asked if they wanted to have another order, and for the output it will print overall receipt. should be like this
ORDER’S NAME: jack
ORDER’S IC : 21124123
FOOD’S ORDERED: Fried Noodle 5USD Quatity: 10
Fried Chicken 10USD Quantity: 5
Fried Rice 3USD Quantity:3
TOTAL FOOD COST: 109USD
THANK YOU HAVE A NICE DAY!
Here is the full Code:
#include
#include
#include
#include<conio.h>
#include
using std::cout;
using std::cin;
using std::endl;
using std::string;
//Base class
class OrderingSystem
{
protected:
string name;
long long icno;
int yourorder;
string food[4]={"Nasi Goreng","Fried Noodles","Roti Canai","Laksa"};
int num[4]={5,5,3,5};
int quantity,x,sum;
public:
void displaymenu()
{
cout<<"\n\n\n\t\t\t\t ========== WELCOME TO FOOD ORDERING SYSTEM =========="<<endl;
cout<<"\n\n\t\t\t\t\t =====CHOOSE YOUR FOOD====="<<endl;
cout<<"\n\n"<<endl;
cout<<"\t\t\t\t\t\t1."<<food[0]<<"\t(RM"<<num[0]<<")"<<endl;
cout<<"\t\t\t\t\t\t2."<<food[1]<<"\t(RM"<<num[1]<<")"<<endl;
cout<<"\t\t\t\t\t\t3."<<food[2]<<"\t(RM"<<num[2]<<")"<<endl;
cout<<"\t\t\t\t\t\t4."<<food[3]<<"\t\t(RM"<<num[3]<<")"<<endl;
cout<<"\n\n\n"<<endl;
}
OrderingSystem(){
}
void stname(string nme1){
name = nme1;
}
string getname(){
return name;
}
void sticno(long long ic1){
icno = ic1;
}
long long gtic(){
return icno;
}
};
class PrintOrderDetails : public OrderingSystem
{
public:
void foodlist()
{
switch(yourorder)
{
case 1:
cout<<"\t\t\t\t"<<food[0]<<endl;
num[0];
cout<<"\t\t\t\tQuantity Of Your Order: ";
cin>>x;
break;
case 2:
cout<<"\t\t\t\t"<<food[1]<<endl;
num[1];
cout<<"\t\t\t\tQuantity Of Your Order: ";
cin>>x;
break;
case 3:
cout<<"\t\t\t\t"<<food[2]<<endl;
num[2];
cout<<"\t\t\t\tQuantity Of Your Order: ";
cin>>x;
break;
case 4:
cout<<"\t\t\t\t"<<food[3]<<endl;
num[3];
cout<<"\t\t\t\tQuantity Of Your Order: ";
cin>>x;
break;
}
}
void printresit()
{
cout<<"\n\n\n\n"<<endl;
cout<<"\t\t\t\tORDER’S NAME:\t\t\t"<<name<<endl;
cout<<"\t\t\t\tORDER’S IC NUMBER:\t\t"<<icno<<endl;
cout<<"\t\t\t\tORDER’S ORDER FOOD LIST:\t"<<*food<<" RM"<<*num<<"\t QUANTITY: “<<x<<endl;
cout<<”\t\t\t\tTOTAL FOOD COST:\t\t"<<“RM”<<numx<<endl;
cout<<"\t\t\t\tTHANK YOU! HAVE A GREAT DAY!"<<endl;
cout<<"\n\n\n\n"<<endl;
}
PrintOrderDetails(){
cout<<"\n\n\n"<<endl;
cout<<"\t\t\t\t\t\tEnter Your Name:\t";
std::getline(std::cin, name);
cout<<"\t\t\t\t\t\tEnter Your IC Number:\t";
cin>>icno;
cout<<"\t\t\t\t\t\tChoose Your Order(1-4):\t";
cin>>yourorder;
cout<<"\n\n\n"<<endl;
}
};
int main()
{
PrintOrderDetails a1;
a1.displaymenu();
a1.foodlist();
system("CLS");
a1.printresit();
return 0;