# A program for restaurant maintain breakfast billing system

## Question

Objective: C++ Struct/Class and Sorting Algorithms
Activity:
** For each question, write pseudocode definition as part of design before going for implementation.
** Please provide sufficient test cases for each question.
Restaurant System
Write a program to help a local restaurant automate its breakfast billing system. The program should do not the following:
a) Show the customer the different breakfast items offered by the restaurant.
b) Allow the customer to select more than one item from the menu.
c) Calculate and print the bill.

 Item Price Plain Egg $1.45 Bacon and Egg$2.45 Muffin $0.99 French Toast$1.99 Fruit Basket $2.49 Cereal$0.69 Coffee $0.50 Tea$0.75

Use an array, menuList, of the class restaurant. Your program contains at least the following functions:

• Function getdata: This function loads the data into the array menuList.
• Next Function showMenu: This function shows the different items offered by the restaurant and tells the user how to select the items.
• Function printCheck: This function calculates and prints the check. (Note: billing will include 5% tax)
Assume that the restaurant offers the following breakfast items and sample output is:
 Welcome to Rachel’s Restaurant Bacon and Egg                                                                                                          $2.45 Muffin$0.99 Coffee                                                                                                                         $0.50 Tax$0.20 Amount Due                                                                                                              $4.14 ## Summary Here in this question, we will create a program for breakfast billing. Where we will provide sufficient test cases for each question. So that we will create a program which program will Show the customer the different breakfast items offered by the restaurant. Customers will select the item from the menu. To create this program we will use different functions and constructors. ## Explanation Here in this breakfast billing system program. Basically first we add the header file i.e. iostream. Next, we add the class with the class name as Restaurant. That class Restaurant includes the data members as menuList, price, orderlist, and orderprice. next we have a default constructor. Next we have a function naming as getData this function has the work of getting data. Which includes a string of all the items in the menu. On the next line, there is a for loop which is used to print a rate of the item on the front of the item name. Next function we use is a showMenu which is used to show the menu. This function will show as well as will get the menu. For that we use a cout statement. And if the customer ants to order more than one item for that purpose a while loop is used. Next function in the program is printCheck in this function there is a nested for loop to print the amount of the items in the menu. After a nested loop, there is a cout statement with a welcome message. Next in the main method, we call the functions using the dot(.)operator. ## Code #include <iostream> using namespace std; #include <iomanip> class restaurant { public: /* members */ string menuList[8]; float price[8]; string orderList[8]; float orderPrice[8]; int cc; /* class constructor */ restaurant(){cc=0;} /* to have the item list to the array with its price */ void getData() { string menu[8]={"Plain Egg","Bacon and Egg","Muffin","French Toast", "Fruit Basket","Cereal","Coffee","Tea"}; float p[8]={1.45,2.45,0.99,1.99,2.49,0.69,0.50,0.75}; for(int i=0;i<8;i++){ menuList[i]=menu[i]; price[i]=p[i]; } } /* to show the items and get the order details */ void showMenu() { cout<<left; cout<<setw(20)<<"Item"<<setw(10)<<"Price"<<endl; for(int i=0;i<8;i++){ cout<<setw(20)<<menuList[i]<<setw(1)<<"$"<<setw(10)<<price[i]<<endl;
}
cout<<endl;
/* if customer wants to order more */
while(true){
string order;
cin.ignore();
cout<<"Enter an item (or enter quit to exit): ";
getline(cin,order);
if(order=="quit")
break;
orderList[cc++]=order;
}
}
/* check the order and print */
void printCheck()
{
float total=0;
for(int i=0;i<cc;i++){
for(int j=0;j<8;j++){
orderPrice[i]=price[j];
total+=price[j];
break;
}
}
}
cout<<left;
cout<<"Hello!! And welcome to Rachel's restaurant"<<endl;
cout<<setw(20)<<"Item"<<setw(10)<<"Price"<<endl;
for(int i=0;i<cc;i++){
cout<<setw(20)<<orderList[i]<<setw(1)<<"$"<<setw(10)<<orderPrice[i]<<endl; } total=total+0.20; cout<<setw(20)<<"Tax"<<setw(10)<<"$0.20"<<endl;
cout<<setw(20)<<"Amount Due"<<setw(1)<<"\$"<<setw(10)<<total<<endl;
}
};
/* Main code */
int main()
{
restaurant m;
m.getData();