Learn how to create aCafe Management System in Cprogramming with features like billing, menu handling, and order management. Today we will make a cafe management system using programming. Those of you who are interested in doing this project, please comment to me to complete the project, how did you like this C project today? Hello friend, I am Tapas, today I am going to do an amazing project for you on this blog, let’s get started.
Table of Contents
ToggleProgram features
- Add Menu Items
- Taking Order
- Generate Bill
- Sale Report
Requirements
- C Programming Basic
- Array and Structure
- File Handling
#include
#include
#include
#define MAX_ITEMS 50
#define MAX_ORDERS 100
struct MenuItem {
int id;
char name[50];
float price;
int quantity;
};
struct Order {
int order_id;
int item_id;
int quantity;
float total;
};
struct MenuItem menu[MAX_ITEMS];
struct Order orders[MAX_ORDERS];
int item_count = 0;
int order_count = 0;
void addMenuItem() {
if(item_count >= MAX_ITEMS) {
printf("Menu is full!\n");
return;
}
printf("\n=== Add New Menu Item ===\n");
menu[item_count].id = item_count + 1;
printf("Enter item name: ");
scanf(" %[^\n]", menu[item_count].name);
printf("Enter price: ");
scanf("%f", &menu[item_count].price);
printf("Enter available quantity: ");
scanf("%d", &menu[item_count].quantity);
printf("Item added successfully! ID: %d\n", menu[item_count].id);
item_count++;
}
void displayMenu() {
printf("\n=== Cafe Menu ===\n");
printf("ID\tName\t\tPrice\tQuantity\n");
printf("--------------------------------\n");
for(int i = 0; i < item_count; i++) {
printf("%d\t%-15s\t%.2f\t%d\n",
menu[i].id,
menu[i].name,
menu[i].price,
menu[i].quantity);
}
}
void takeOrder() {
if(item_count == 0) {
printf("No items in menu!\n");
return;
}
printf("\n=== Take New Order ===\n");
displayMenu();
int item_id, quantity;
printf("\nEnter Item ID: ");
scanf("%d", &item_id);
if(item_id < 1 || item_id > item_count) {
printf("Invalid Item ID!\n");
return;
}
printf("Enter quantity: ");
scanf("%d", &quantity);
if(quantity > menu[item_id-1].quantity) {
printf("Not enough quantity available!\n");
return;
}
// Create order
orders[order_count].order_id = order_count + 1;
orders[order_count].item_id = item_id;
orders[order_count].quantity = quantity;
orders[order_count].total = menu[item_id-1].price * quantity;
// Update stock
menu[item_id-1].quantity -= quantity;
printf("Order placed successfully! Order ID: %d\n", orders[order_count].order_id);
printf("Total amount: %.2f\n", orders[order_count].total);
order_count++;
}
void generateBill() {
if(order_count == 0) {
printf("No orders found!\n");
return;
}
int order_id;
printf("\nEnter Order ID to generate bill: ");
scanf("%d", &order_id);
if(order_id < 1 || order_id > order_count) {
printf("Invalid Order ID!\n");
return;
}
struct Order order = orders[order_id-1];
struct MenuItem item = menu[order.item_id-1];
printf("\n=== Bill ===\n");
printf("Order ID: %d\n", order.order_id);
printf("Item: %s\n", item.name);
printf("Quantity: %d\n", order.quantity);
printf("Price per item: %.2f\n", item.price);
printf("Total amount: %.2f\n", order.total);
printf("Thank you for your order!\n");
}
void salesReport() {
printf("\n=== Sales Report ===\n");
printf("Total orders: %d\n", order_count);
float total_revenue = 0;
for(int i = 0; i < order_count; i++) {
total_revenue += orders[i].total;
}
printf("Total revenue: %.2f\n", total_revenue);
}
int main() {
int choice;
printf("=== Welcome to Cafe Management System ===\n");
do {
printf("\n1. Add Menu Item\n");
printf("2. Display Menu\n");
printf("3. Take Order\n");
printf("4. Generate Bill\n");
printf("5. Sales Report\n");
printf("6. Exit\n");
printf("Enter your choice: ");
scanf("%d", &choice);
switch(choice) {
case 1:
addMenuItem();
break;
case 2:
displayMenu();
break;
case 3:
takeOrder();
break;
case 4:
generateBill();
break;
case 5:
salesReport();
break;
case 6:
printf("Thank you for using Cafe Management System!\n");
break;
default:
printf("Invalid choice! Please try again.\n");
}
} while(choice != 6);
return 0;
}
Output
=== Welcome to Cafe Management System ===
1. Add Menu Item
2. Display Menu
3. Take Order
4. Generate Bill
5. Sales Report
6. Exit
Enter your choice: 1
=== Add New Menu Item ===
Enter item name: Cappuccino
Enter price: 120.50
Enter available quantity: 50
Item added successfully! ID: 1
Enter your choice: 1
=== Add New Menu Item ===
Enter item name: Chocolate Cake
Enter price: 85.00
Enter available quantity: 30
Item added successfully! ID: 2
Enter your choice: 2
=== Cafe Menu ===
ID Name Price Quantity
--------------------------------
1 Cappuccino 120.50 50
2 Chocolate Cake 85.00 30
Enter your choice: 3
=== Take New Order ===
=== Cafe Menu ===
ID Name Price Quantity
--------------------------------
1 Cappuccino 120.50 50
2 Chocolate Cake 85.00 30
Enter Item ID: 1
Enter quantity: 2
Order placed successfully! Order ID: 1
Total amount: 241.00
Enter your choice: 4
Enter Order ID to generate bill: 1
=== Bill ===
Order ID: 1
Item: Cappuccino
Quantity: 2
Price per item: 120.50
Total amount: 241.00
Thank you for your order!
Enter your choice: 5
=== Sales Report ===
Total orders: 1
Total revenue: 241.00
Enter your choice: 6
Thank you for using Cafe Management System!
