You are on page 1of 31

UNIVERSITI TEKNOLOGI MARA

CSC404 PROGRAMMING II

MINI PROJECT : BURGER SHOP

PREPARED BY

IZZATUL SYAHIRAH BT ISMAIL (2019405594)

SITI HAJAR AISHAH BT SAMSUDIN(2019252346)

GROUP
CS2302B2

PREPARED FOR

MADAM NORLINA BINTI MOHD SABRI

DATE OF SUBMISSION

26TH JULY 2020


1.0 INTRODUCTION OF APPLICATION PROGRAM
This application program is for Zatohajo burger shop. It is an application that helps
the workers to deal with the orders from the customer. The program will store the information
about the burger’s menu, workers, sales, customers, and print the receipt for the customer.
This application also can help the workers to calculate the total price for customers without
any mistakes by only entering the customer's orders choice and quantity on the application.
They don’t need to do the manual calculation to get the total price. The idea of this
application is to make Zatohajo burger shop to become more up to date with current
technology and IT facilities. This brings the meaning to make conducting its orders using a
program and not using the old traditional way which is taking orders from customers by
writing the order on a piece of paper. Thus, it helps the workers in making the ordering faster
and with accuracy.

In our application program, there are 3 structs that we use to store the information.
The structs are “Burgers”, “CustomerOrder”, and “WorkerInfo”. In Burger’s struct, the
members are burgername, price, and drink. For CustomerOrder’s struct, the members are
choice, custname, qty (quantity), totalpay, burger, and drink. Lastly, for WorkerInfo’s struct,
the members are name, age, workhour, hourrate, and salary. Our program implements 6
functions. The first function is “displaymenu” and it is displayed on the terminal. It is used to
display the menu which is the burger's name, price, and drink that we served in our burger
shop.The menu that is displayed on the terminal is read from the “inputmenu” function.
“inputmenu” function reads the menu from the BurgersMenu.txt. Next is, “displayreceipt”
function that is used to show the receipt for the customers and it is written into Receipt.txt.

Next function is “calcaveragentotal”. As the name suggests, it will calculate the total
pay from all the customers and we declared it as our total sale. Based on our customers'
number on that day, we will calculate the average. Both total sale and average are written into
a text file named SalesReport.txt. The next function is “maxmin”. This function will find the
maximum and minimum sale for today and display the total pay. The last function is the
function “search”. This function will search the customers who spent over RM50 and display
the customers name and the total pay if the bool found returns true. Else, it will display the
message “No customers have total pay above RM 50”. All the functions that were used are
void type.
There are many 1-dimensional arrays that can be found in our application program as
we declared it as the variable of structs. For CustomerOrder struct, we declared an array
named “customer” sized 200. For Burgers struct, we declared an array named “combo” sized
5. For the last struct which is the WorkerInfo struct, we declared an array named “worker”
with the size of 5. Another 1D array that we used is the “totalbonus” with the size of 5 as we
have 5 workers. While for the 2-dimensional array, we have a “bonus” array with row size 5
and column size 200. Row size is following the number of workers and the column size is
depending on the number of customers. We used nested loops for calculating the values that
we want to store in the “bonus” array. For pointer, we declared variable p as a pointer and
assigned it to address value of totalcust to calculate the total customer that came to our shop
on that day.

In conclusion, the program code is created to smoothen our shop management and
help us to see a clearer vision of our shop’s future since it has all the techniques and
functionality in the program, which in less time will improve the burger shop business and
give a brighter opportunity to become successful. This application helps our business in
many ways, such as expanding our business branch and becoming a franchise, helps the
business to target more customers, gives a boost to our business sales and improves the
quality services within time. Lastly, this program will ensure the workers get the total salary
that they deserved since no mistake could happen when calculating their bonus using this
program code

2.0 PURPOSE OF APPLICATION

The purpose of this program code is to collect all the data that are related to our shop.
Firstly, we want to display our shop menu and price to our customers. We want to help
customers in making their orders and let our customers know about our special burgers’
names which are only available at our shop. This program will read the data from a text file
named BurgersMenu.

This program code will ask the customer's choice, name, and quantity. The customer’s
choice will determine the burger combo he or she will get and the total pay for his or her
order based on the quantity. All of this information will be recorded and written into a text
file named Receipt. From the customer's total pay, this program will search the customers
who pay above RM 50 and write the information into a text file named SalesReport. The
sales report also stores the total customers, total pay for all the customers, and finds the
average pay for each customer for one day of business. This program code will also
determine the minimum and maximum customers’ pay and store into this SalesReport textfile
too.

Not only that, the program code will also read the worker's information from the
WorkersData text file that contains name, age, work hour, and rate per hour of the workers.
Then, from work hour and rate per hour, the program code will calculate the salary of each
worker. The total bonus will be added to the salary to get the final salary amount for each
worker. The bonus is gained from 0.05% of each customer's total pay. All of the workers'
information will be written into a text file named WorkersReport.

3.0 THE TARGET USER AND LIMITATION OF PROGRAM

The application program will be used by the workers since they need to input the
customer’s orders. There are two limitations that we have in this program code. First, the
number of customers that we can receive in a day. For the number of customers, we can only
receive 200 customers per day. The total customers can be less than 200 depends on the total
customers buying burger for that day. It does not mean it has to be totally 200 customers but
the maximum capita of customers we can receive is only 200. The next limitation is this
program is only able to get the data for one day of business. In order to save the data for
another day of business, we have to create the new text file for every day we run our
business, or we have to clear the previous information that we have stored before.
4.0 SOURCE CODE

//IZZATUL SYAHIRAH BINTI ISMAIL(2019405594)


//SITI HAJAR AISHAH BINTI SAMSUDIN (2019252346)
//GROUP : CS2302B2
// A PROGRAM TO TAKE BURGER'S ORDER FROM CUSTOMER AND DISPLAY THE
RECEIPT, DISPLAY SALARY REPORT FOR WORKERS AND DISPLAY SALE
//header
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <sstream>
#include <bits/stdc++.h>
#include <vector>
using namespace std;
struct Burgers{ //struct for burgers
string burgername; //declare variable burgername
float price; //declare variable price
string drink; //declare variable drink
};
struct CustomerOrder{ //struct for CustomerOrder
int choice; //declare variable choice
string custname; //declare variable custname
int qty; //declare variable qty
float totalpay; //declare variable totalpay
string burger; //declare variable burger
string drink; //declare variable drink
};
struct WorkerInfo{ //struct for workers
string name; //declare variable name
int age; //declare variable age
int workhour; //declare variable workhour
float hourrate; //declare variable hourrate
float salary; //declare variable salary
};

void displaymenu(Burgers[]); //function prototype to displaymenu


void inputmenu(ifstream&, Burgers[]); //function prototype to read menu from text file
void displayreceipt(ofstream&, CustomerOrder[], int); //function prototype to display receipt
on text file
void avgntotal(ofstream&, CustomerOrder[], int); //function prototype to calculate average
void maxmin(ofstream&, CustomerOrder[], int); //function prototype to find maximum and
minimum
void search(ofstream&, CustomerOrder[], int, bool); //function prototype to search

int main(){
//declare struct variable into array
CustomerOrder customer[200];
WorkerInfo worker[5];
Burgers combo[5];
int totalcust=0; //declare variable totalcust
totalcust=0; //initialize totalcust
int *p; //declare variable pointer
p=&totalcust; //assign address to variable pointer
int x = 0; //counter for array customer in do while loop
float totalsale=0; //declare and initialize totalsale
float average; //declare average
char next; //declare variable next
bool found = false; //declare and initialize variable found
float bonus[5][200]; //declare 2d array [5]-worker [200]-customer
float totalbonus[5]; //declare 1d array [5]-worker
//reading data and open the input file
ifstream order("BurgersMenu.txt");

//writing data and open the output file


ofstream receipt("Receipt.txt");
ofstream sale("SalesReport.txt");

inputmenu(order, combo); //function call for inputmenu function


displaymenu(combo); //function call for displaymenu function

for (int x=0; x<200; x++){ //getting order from customers


if(x!=0){cin.ignore();}
cout << "Which set would you like to order? \nSet: "; //prompt user to enter set
cin >> customer[x].choice; //user input set
cout << "Your name: "; //prompt user to enter name
cin >> customer[x].custname; //user input name
cout << "Quantity order: "; //prompt user to input quantity
cin >> customer[x].qty; //user input quantity

//burger, drink and totalpay based on their choice on set


if (customer[x].choice == 1){
customer[x].burger = combo[0].burgername;
customer[x].drink = combo[0].drink;
customer[x].totalpay = combo[0].price * customer[x].qty;}

else if (customer[x].choice == 2){


customer[x].burger = combo[1].burgername;
customer[x].drink = combo[1].drink;
customer[x].totalpay = combo[1].price * customer[x].qty;}

else if (customer[x].choice == 3){


customer[x].burger = combo[2].burgername;
customer[x].drink = combo[2].drink;
customer[x].totalpay = combo[2].price * customer[x].qty;}

else if (customer[x].choice == 4){


customer[x].burger = combo[3].burgername;
customer[x].drink = combo[3].drink;
customer[x].totalpay = combo[3].price * customer[x].qty;}

else if (customer[x].choice == 5){


customer[x].burger = combo[4].burgername;
customer[x].drink = combo[4].drink;
customer[x].totalpay = combo[4].price * customer[x].qty;}

else{
cout << "This combo is not exist in our menu." << endl;} //display if the set is not in
menu
cout << "Total pay: RM "<<fixed<<setprecision(2) << customer[x].totalpay << endl;
//display totalpay
totalcust++; //count total customer

cout << "Next customer? [Y-Yes || N-No]"<<endl; //ask user to continue or not
cin >> next; //user input
if (next=='N'||next=='n'){ //condition for No answer
break;} //to stop
cout << endl << endl;
}

sale << "TOTAL CUSTOMER OF ZATOHAJO BURGER SHOP FOR TODAY IS "<<
totalcust <<endl; //display totalcust in textfile
displayreceipt(receipt, customer, *p); //function call for displayreceipt function
avgntotal(sale, customer, *p); //function call for calcaveragentotalsale function
maxmin(sale, customer, *p); //function call for maxmin function
search(sale, customer, *p, found); //function call for search function
//close order, receipt,sale files
order.close();
receipt.close();
sale.close();
ifstream workdata("WorkersData.txt"); //reading data and open the input file
ofstream workreport("WorkersReport.txt"); //writing data and open the output file

//reading worker information from textfiles


workreport << "ZATOHAJO WORKERS SALARY CALCULATION" << endl;

for(int i=0; i<5; i++){


getline (workdata, worker[i].name, ';'); //read name
workdata >> worker[i].age >> worker[i].workhour >> worker[i].hourrate; //read
worker's age, workhour, hourrate
worker[i].salary = worker[i].hourrate * worker[i].workhour; //calculate salary
for 5 worker
workreport << "WORKER "<< i+1 << endl;
workreport << "Workers salary (without bonus): RM " << fixed <<
setprecision(2) << worker[i].salary<<endl; //display salary without bonus

for (int j=0; j<totalcust; j++){


bonus[i][j] = 0.05*customer[j].totalpay; //calculate bonus
totalbonus[i]+=bonus[i][j]; //calculate total bonus
}
workreport << "Total bonus for Worker: RM "<< fixed <<
setprecision(2) << totalbonus[i] << endl; //display totalbonus
worker[i].salary = worker[i].hourrate * worker[i].workhour +
totalbonus[i]; //calculate worker salary with bonus
workreport << "Workers salary (with bonus): RM " << fixed <<
setprecision(2) << worker[i].salary << endl; //display salary
workreport << endl << endl;
}
//writing workers information into textfile
workreport << "
\n\n\t#############################################################" << endl;
workreport <<" ZATOHAJO WORKERS INFORMATION"<<endl;
workreport << setw(15) << "NAME \t\t" << setw(15) << "AGE \t WORK HOUR \t"
<< "HOUR RATE(RM) \t SALARY(RM)" << endl;

for (int i=0; i<5; i++){


workreport << worker[i].name << setw(13); //write worker's name into textfile
workreport << worker[i].age << setw(13); //write worker's age into textfile
workreport << worker[i].workhour << setw(13); //write worker's workhour into
textfile
workreport << worker[i].hourrate << setw(20); //write worker's hourrate into textfile
workreport << worker[i].salary; //write worker's salary into textfile
workreport << endl;
}
//close workdate and workreport files
workdata.close();
workreport.close();
}
void displaymenu(Burgers combo[]){ //function definition for displaymenu
cout <<
"#####################################################################" <<
endl;
cout << " WELCOME TO THE ZATOHAJO BURGER SHOP" << endl;
cout << setw(15) << "SET" << setw(18) << "BURGER NAME" << setw(18) <<
"PRICE(RM)" << setw(13) << "DRINK" << endl;

for (int i=0; i<5; i++){


cout << setw(15) << i+1 << setw(20) ;
cout << combo[i].burgername << setw(13); //display burgername
cout << combo[i].price << setw(20); //display price
cout << combo[i].drink << setw(20); //display drink
cout << setw(20) << endl << endl;}
}

void inputmenu(ifstream &order, Burgers combo[]){ //function definition for inputmenu


function
string tokens[6]; //declare tokens into array
string line; //declare line
int j = 0; // declare and initialize j

while (order.good()){
int i = 0; //initialize i
getline(order, line);
stringstream ss (line); //convert into string stream
string temp; //declare temp
while (getline (ss, temp, ';')){ //use semicolon as delimeter for cutting string
tokens[i] = temp; //assign token to temp
i++;
}
combo[j].burgername = tokens[0];
combo[j].price = atof(tokens[1].c_str()); //string to float
combo[j].drink = tokens[2];
j++;} //increament by 1
}
void displayreceipt(ofstream &receipt, CustomerOrder customer[], int totalcust){//function
definition for display function
//display receipt for customer
for (int i=0; i<totalcust; i++){
receipt << "THANK YOU " << customer[i].custname << " \nTHIS IS YOUR
RECEIPT." << endl;
receipt << setw(15) << "CHOICE"<< setw(18) <<"BURGER" << setw(18)
<< "DRINK" << setw(20) << "QUANTITY" << endl;
receipt << setw(15) << "------"<< setw(18) <<"------" << setw(18) <<"-----"
<< setw(20) <<"--------" << endl;
receipt << setw(15) << customer[i].choice << setw(20) ;
receipt << customer[i].burger << setw(10) <<" ";
receipt << customer[i].drink << setw(10) <<" ";
receipt << customer[i].qty;
receipt << endl << endl << "TOTAL PAY : RM "<< fixed << setprecision(2) <<
customer[i].totalpay << endl ; //display totalpay
receipt << "PLEASE COME AGAIN :) " << endl << endl;}
}

void avgntotal(ofstream &sale, CustomerOrder customer[], int totalcust){ //function


definition avgntotal function

//write average and total sale in textfiles


sale << endl<< endl<< "Calculating total sale and sale average for today... \n\n"<<
endl;
float totalsale = 0; //declare and initialize totalsale
float average; //declare average
for (int x=0; x<totalcust; x++){
totalsale+=customer[x].totalpay;} //calculate totalsale
sale << "Total sale for today is RM " << fixed << setprecision(2) << totalsale << "."
<< endl; //display totalsale

average = totalsale/totalcust; //calculate average


sale << "Average sales per day is RM " << average << endl; //display average
}

void maxmin(ofstream &sale, CustomerOrder customer[], int totalcust){ //function definition


for maxmin function
float max = 0; //declare and initialize max
float min = 999; //declare and initialize min

for (int i=0; i<totalcust; i++){


//to find max totalpay
if(customer[i].totalpay > max){
max = customer[i].totalpay;}
//to find min totalpay
if(customer[i].totalpay < min){
min = customer[i].totalpay;}
}
//write max and min in textfiles
sale << endl<< endl<<"Searching for maximum and minimum total pay for today...
\n\n"<< endl;
sale << "Maximum total pay for today is RM" << max << endl;
sale << "Minimum total pay for today is RM" << min << endl;
}

void search(ofstream &sale, CustomerOrder customer[], int totalcust, bool found){ //function
definition for search function

//to search customer who spent over 50


sale << endl<< endl<<"Searching for customers who spent over RM 50 for today...
\n\n"<< endl;
for(int i=0; i<totalcust; i++){
if(customer[i].totalpay > 50 ){
sale <<"Customer that have total pay above RM 50 " << endl;
sale << "Customer name : " << customer[i].custname << endl;
//display customer name
sale << "Total pay : RM" <<customer[i].totalpay << endl; //display
totalpay
found = true;}
}
if (found == false){
sale << "No customer have total pay above RM 50" << endl;}
}
5.0 INPUT OUTPUT SAMPLE
SAMPLE 1

Figure 1. BurgersMenu text file

Figure 2. Workersdata text file


Figure 3. Terminal to input customer’s order
Figure 4. Receipt for customer in text file
Figure 5. SalesReport text file
Figure 6. WorkersReport text file
SAMPLE 2

Figure 7. BurgersMenu text file

Figure 8. Workersdata textfile


Figure 9. Terminal to input customer’s order
Figure 10. Receipt text file to display for customer’s orders
Figure 11. SalesReport text file
Figure 12. WorkersReport textfile
SAMPLE 3

Figure 13. BurgersMenu text file

Figure 14. Workersdata text file


Figure 15. Terminal to input customer’s order
Figure 16. Receipt text file to display customer’s orders
Figure 17. SalesReport text file
Figure 18. WorkersReport text file

You might also like