CAFETERIA ORDER MANAGEMENT SYSTEM
Submitted by : Aadharishini.S(22IT001)
Harish.T(22IT051)
Department : Information Technology
Month : April2023 - May2023
Abstract:
The aim of the cafeteria order management program is to provide a simple and efficient
way for users to manage and process food orders in a cafe setting. The program should allow
users to view the menu, take orders, display existing orders, calculate the total bill for each order,
and exit the system.
Algorithm:
1.Define the MenuItem and OrderItem structures to hold information about menu items
and order items, respectively. The MenuItem structure should store the name and price of each
menu item, while the OrderItem structure should store the name and quantity of each ordered
item.
2.Create functions to handle various operations:
display_menu: Display the list of menu items with their prices.
take_order: Prompt the user to enter the order details, i.e., select items from the menu and
specify the quantity for each item. Store the order in an array of OrderItem structures.
calculate_total_bill: Calculate the total bill for a given order based on the selected menu
items and quantities.
display_orders: Display all the orders placed so far, showing the items ordered along with
their quantities for each order.
3.In the main function, initialize the menu array with the predefined menu items and their
prices.
4.Use a loop to present a menu of options to the user:
If the user chooses to take an order, call the take_order function to take the order
and store it in an array of OrderItem structures.
If the user chooses to view existing orders, call the display_orders function to
display all the orders placed so far.
If the user chooses to calculate the total bill for an order, call
the display_orders function to display the existing orders and prompt *the user to
select an order. Then, call the calculate_total_bill function to calculate and display
the total bill for the selected order.
If the user chooses to exit the system, terminate the program.
If the user selects an invalid option, display an error message and prompt the user to
select again.
5.The program will keep running in the loop until the user chooses to exit the system.
Program:
#include <stdio.h>
#include <string.h>
#define MAX_MENU_ITEMS 5
#define MAX_ORDER_ITEMS 10
struct MenuItem
{
char name [50];
float price;
};
struct OrderItem
{
char name [50];
int quantity;
};
void display_menu(struct MenuItem menu[], int size)
{
printf ("Menu:\n");
for (int i = 0; i < size; i++)
{
printf("%d. %s - $%.2f\n", i + 1, menu[i].name, menu[i].price);
}
}
void take_order(struct MenuItem menu[], int menu_size, struct OrderItem order[], int* order_size)
{
printf("Enter 'q' to finish the order.\n");
*order_size = 0;
while (*order_size < MAX_ORDER_ITEMS)
{
char item_name[50];
printf("Enter item: ");
scanf("%s", item_name);
if (strcmp(item_name, "q") == 0)
{
break;
}
int quantity;
printf("Enter quantity: ");
scanf("%d", &quantity);
int item_found = 0;
for (int i = 0; i < menu_size; i++)
{
if (strcmp(item_name, menu[i].name) == 0)
{
strcpy(order[*order_size].name, item_name);
order[*order_size].quantity = quantity;
(*order_size)++;
item_found = 1;
break;
}
}
if (!item_found)
{
printf("Invalid item. Please try again.\n");
}
}
}
float calculate_total_bill(struct MenuItem menu[], int menu_size, struct OrderItem order[], int
order_size)
{
float total_bill = 0;
for (int i = 0; i < order_size; i++)
{
for (int j = 0; j < menu_size; j++)
{
if (strcmp(order[i].name, menu[j].name) == 0)
{
total_bill += menu[j].price * order[i].quantity;
break;
}
}
}
return total_bill;
}
void display_orders(struct MenuItem menu[], int menu_size, struct OrderItem orders[]
[MAX_ORDER_ITEMS], int num_orders)
{
printf("Orders:\n");
for (int i = 0; i < num_orders; i++)
{
printf("Order %d:\n", i + 1);
for (int j = 0; j < MAX_ORDER_ITEMS; j++)
{
if (orders[i][j].quantity > 0)
{
printf("%s: %d\n", orders[i][j].name, orders[i][j].quantity);
}
}
}
}
int main()
{
struct MenuItem menu[MAX_MENU_ITEMS] = {
{ "Americano", 10 },
{ "Cappuccino", 12 },
{ "Espresso", 8 },
{ "Macchiato De Menta", 6 },
{ "Café Latte", 2 }
};
struct OrderItem orders[MAX_ORDER_ITEMS][MAX_ORDER_ITEMS];
int num_orders = 0;
while (1) {
printf("\n1. Take Order\n");
printf("2. View Orders\n");
printf("3. Calculate Total Bill\n");
printf("4. Exit\n");
int choice;
printf("Enter your choice: ");
scanf("%d", &choice);
switch (choice)
{
case 1:
take_order(menu, MAX_MENU_ITEMS, orders[num_orders], &num_orders);
break;
case 2:
display_orders(menu, MAX_MENU_ITEMS, orders, num_orders);
break;
case 3:
if (num_orders == 0)
{
printf("No orders placed yet.\n");
}
else
{
display_orders(menu, MAX_MENU_ITEMS, orders, num_orders);
int order_idx;
printf("Enter the order number to calculate the bill: ");
scanf("%d", &order_idx);
if (1 <= order_idx && order_idx <= num_orders)
{
float total_bill = calculate_total_bill(menu, MAX_MENU_ITEMS, orders[order_idx - 1],
MAX_ORDER_ITEMS);
printf("Total Bill for Order %d: $%.2f\n", order_idx, total_bill);
}
else
{
printf("Invalid order number. Please try again.\n");
}
}
break;
case 4:
printf("Thank you for using the Cafeteria Order Management System!\n");
return 0;
default:
printf("Invalid choice. Please try again.\n");
}
}
return 0;
}
Output:
1. Take Order
2. View Orders
3. Calculate Total Bill
4. Exit
Enter your choice: 1
Enter 'q' to finish the order.
Enter item: Americano
Enter quantity: 2
Enter item: Cappuccino
Enter quantity: 1
Enter item: q
1. Take Order
2. View Orders
3. Calculate Total Bill
4. Exit
Enter your choice: 1
Enter 'q' to finish the order.
Enter item: Cafe Latte
Enter quantity: 3
Enter item: Espresso
Enter quantity: 2
Enter item: q
1. Take Order
2. View Orders
3. Calculate Total Bill
4. Exit
Enter your choice: 2
Orders:
Order 1:
Americano: 2
Cappuccino: 1
Order 2:
Cafe Latte: 3
Espresso: 2
1. Take Order
2. View Orders
3. Calculate Total Bill
4. Exit
Enter your choice: 3
Orders:
Order 1:
Americano: 2
Cappuccino: 1
Order 2:
Cafe Latte: 3
Espresso: 2
Enter the order number to calculate the bill: 2
Total Bill for Order 2: $54.00
1. Take Order
2. View Orders
3. Calculate Total Bill
4. Exit
Enter your choice: 4
Thank you for using the cafeteria Order Management System!
Conclusion:
The result of the cafeteria order management program is an interactive console-based
application where users can perform the following tasks:
1. View the menu: Display the list of available menu items along with their prices.
2. Take orders: Allow users to place drink orders by selecting items from the menu and specifying the
quantity.
3. View existing orders: Display all the orders placed so far, showing the items ordered along with their
quantities for each order.
4. Calculate total bill: Calculate and display the total bill for a specific order based on the selected
menu items and quantities.
5. Exit the system: Allow users to exit the order management system when they are done.