Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need to add header file and pointer in this code by c++: #include #include using namespace std; int numberOfItems=0; bool found=false; struct ord{ string

I need to add header file and pointer in this code by c++:
#include
#include
using namespace std;
int numberOfItems=0;
bool found=false;
struct ord{
string food;
double price;
int val;
};
void choices()
{
cout<<"Press "
<< " a. BreakFast "
<<" b. Lunch / Dinner ";
}
void breakfastMenu()
{
cout<<"\t\t\t\t **BreakFast Menu** "
<<"\t\t\t\t_________________________________ "
<<"\t\t\t\t\t -- BreakFast -- "
<<" \t\t\t\t(1) French Toast\t 25 SR "
<<" \t\t\t\t(2) Waffle\t\t 20 SR "
<<" \t\t\t\t(3) Pancake\t\t 30 SR "
<<" \t\t\t\t(4) Mini pancake for kids 12 SR "
<<"\t\t\t\t\t -- Drinks -- "
<<" \t\t\t\t(5) Coffee latte\t 12 SR "
<<"\t\t\t\t(6) Black coffee\t 10 SR "
<<"\t\t\t\t(7) Orange juice\t 10 SR "
<<"\t\t\t\t(8) Water\t 10 SR "
<<"\t\t\t\t_________________________________ ";
cout<
}
void lunchMenu()
{
cout<<"\t\t\t\t **Lunch | Dinner Menu** "
<<"\t\t\t\t ___________________________________ "
<<"\t\t\t\t\t -- Lunch -- "
<<" \t\t\t\t (1) Pasta \t\t 35 SR "
<<" \t\t\t\t (2) Chicken Burger\t 25 SR "
<<" \t\t\t\t (3) Pizza\t\t 45 SR "
<<" \t\t\t\t (4) Kids meal\t\t 15 SR "
<<"\t\t\t\t\t -- Drinks -- "
<<"\t\t\t\t (5) Cola\t\t 6 SR "
<<"\t\t\t\t (6) Diet cola\t\t 6 SR "
<<"\t\t\t\t (7) Water \t\t 2 SR "
<<"\t\t\t\t ___________________________________ ";
}
void addOrder( ord order[],int numOfmeals)
{
do
{
cin.ignore();
cout<<"Enter the name of the meal / drink ["<
getline(cin,order[numberOfItems].food);
cout<<"Enter the price of meal / drink ["<
cin>>order[numberOfItems].price;
numberOfItems++;
}
while (numberOfItems < numOfmeals) ;
}
void deleteOrder(ord order[])
{
string target;
cout<<"Enter the order you want to cancel: ";
cin.ignore();
getline(cin,target);
found = false;
for(int i = 0 ; i < numberOfItems; i++ )
{
if(order[i].food == target )
{
for(int j = i ; j < numberOfItems-1 ; j++)
{
order[j]=order[j+1];
}
numberOfItems--;
cout<<"[ Order deleted ] ";
found=true;
break;
}
}
}
void updateOrder(ord order[])
{
string target;
found=false;
cout<<"Enter name of the meal / drink you want to update: ";
cin.ignore();
getline(cin, target);
for(int i = 0 ; i < numberOfItems; i++)
{
if(order[i].food == target)
{
found=true;
cout<<"Enter new order: ";
getline(cin, order[i].food);
cout<<"Enter new price: ";
cin>>order[i].price;
cout<<" [ Order has been update ] ";
found=true;
break;
}
}
if(found == false)
{
cout<<" Order not found ";
}
}
void printOrder(ord order[])
{
cout<<"Your order: ";
for(int i = 0 ; i < numberOfItems ; i++)
{
cout<< "("<
}
cout<
}
void CheckOrder(ord order[])
{
string target;
cout<<"Enter the name of meal/drink you want to check: ";
cin>>target;
found=false;
for(int i = 0 ; i < numberOfItems; i++)
{
if(order[i].food== target){
found=true;
cout<<"Order found in: "<
}
}
if(found==false)
cout<<" Order not found ";
}
double ChekeTotalPrice(ord order[])
{
double sum=0;
for(int i = 0; i < numberOfItems; i++)
{
sum+=order[i].price;
}
cout<<"Subtotal "<
cout<<"VAT (20.0%) "<
cout<<"Total "<
return sum;
}
void sortingOrder(ord order[])
{
bool ordered=false;
ord temp;
for(int i = 0 ; i < numberOfItems-1 && ordered == false ; i++)
{
ordered=true;
for(int j = 0 ; j
{
if(order[j].price
{
ordered=false;
temp=order[j];
order[j]=order[j+1];
order[j+1]=temp;
}
}
}
for(int i = 0 ; i < numberOfItems ; i++)
cout<
}
void bill(ord order [])
{
int numOfmeals;
cout<<"\tITALIAN RESTAURANT ";
cout<<"_______________________________ ";
cout<<" Your Order ";
sortingOrder(order);
cout<
ChekeTotalPrice(order);
cout<<"_______________________________ ";
}
int main()
{
int val;
int numOfmeals;
ord order[numOfmeals];
char choice;
cout<<"How many dishes do you want to order (Enter a number) : ";
cin>>numOfmeals;
do
{
if(numOfmeals > 0 )
{
cout<<" [0]. Exit [1]. Add new order [2]. Delete order [3]. Update order [4]. View all order [5]. Check the order [6]. Check the total price [7]. Get the bill ";
cout<<" Choose from the selction: ";
cin>>val;
cout<
switch(val)
{
case 0:
cout<<"Thank you for visiting us ";
case 1:
if(numberOfItems
{
choices();
cout<<"PLEASE CHOOSE FROM THE SELCTION "<<"[ ]\b\b\b";
cin>>choice;
cout<<" ";
if(choice == 'A'|| choice == 'a' )
{
breakfastMenu();
addOrder(order, numOfmeals);
}
else if (choice == 'B'|| choice == 'b')
{
lunchMenu();
addOrder(order, numOfmeals);
}
else
cout<<" Invalid input ";
}
else
cout <<"[The array is full, you need to delete Order to add new one.] " ;
break;
case 2:
if(numberOfItems> 0)
{
deleteOrder(order);
}
else
cout<<" No order to cancle ";
break;
case 3:
if(numberOfItems> 0)
{
updateOrder(order);
}
else
cout<<" Nothing to update ";
break;
case 4:
if(numberOfItems> 0)
{
printOrder( order);
}
else
cout<<" Nothing to print ";
break;
case 5:
if(numberOfItems> 0)
{
CheckOrder(order);
}
else
cout<<" Nothing to check ";
break;
case 6:
if(numberOfItems> 0)
{
ChekeTotalPrice(order);
}
else
cout<<" Nothing to check ";
break;
case 7:
bill(order);
break;
}
}
}
while (val!=0 ) ;
return 0;
}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts of Database Management

Authors: Philip J. Pratt, Mary Z. Last

8th edition

1285427106, 978-1285427102

More Books

Students also viewed these Databases questions

Question

What is your greatest strength?

Answered: 1 week ago