0% found this document useful (0 votes)
24 views2 pages

Team 5

This document is a C program for a Hotel Food Ordering System that allows customers to order food items from a predefined menu and calculate the total bill including tax. It defines a structure for food items, provides options to order food, generate a bill, and exit the program. The program handles user input and displays the total amount due after applying a 5% tax on the total food charges.

Uploaded by

firehi561
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views2 pages

Team 5

This document is a C program for a Hotel Food Ordering System that allows customers to order food items from a predefined menu and calculate the total bill including tax. It defines a structure for food items, provides options to order food, generate a bill, and exit the program. The program handles user input and displays the total amount due after applying a 5% tax on the total food charges.

Uploaded by

firehi561
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

#include <stdio.

h>
#include <string.h>
#define MAX_FOODS 5
#define TAX_RATE 0.05 // Tax rate (5%)

int main() {
// Structure to store food item details
struct FoodItem {
char name[50];
float price;
};

// Function to calculate the total bill


float calculateBill(float totalAmount) {
float tax = totalAmount * TAX_RATE;
return totalAmount + tax;
}

struct FoodItem menu[MAX_FOODS] = {


{"Dosa", 20.00},
{"Pongal", 50.00},
{"Samosa", 15.00},
{"White rice", 50.00},
{"Chicken masala", 100.00}
};

int choice, quantity;


float totalAmount = 0.0;
char customerName[50];

printf("Welcome to the Hotel Food Ordering System!\n");

printf("Enter customer name: ");


getchar(); // To consume the newline character left by previous input
scanf("%49s", customerName);

while (1) {
printf("\nMenu:\n");
for (int i = 0; i < MAX_FOODS; i++) {
printf("%d. %s - Rs%.2f\n", i + 1, menu[i].name, menu[i].price);
}

printf("\nPlease choose an option:\n");


printf("1. Order Food\n");
printf("2. Generate Bill\n");
printf("3. Exit\n");
printf("Enter your choice: ");
scanf("%d", &choice);

if (choice == 1) {
// Order food
printf("\nEnter food item number (1-%d): ", MAX_FOODS);
scanf("%d", &choice);

if (choice < 1 || choice > MAX_FOODS) {


printf("Invalid food item number!\n");
} else {
printf("Enter quantity: ");
scanf("%d", &quantity);
totalAmount += menu[choice - 1].price * quantity;
printf("Added %d x %s to your order. Total amount: Rs%.2f\n",
quantity, menu[choice - 1].name, totalAmount);
}
}
else if (choice == 2) {
// Generate bill
if (totalAmount == 0) {
printf("No items ordered yet. Please order food first.\n");
} else {
float finalAmount = calculateBill(totalAmount);
printf("\nGenerating Bill for %s\n", customerName);
printf("Total Food Charges: Rs%.2f\n", totalAmount);
printf("Tax (5%%): Rs%.2f\n", finalAmount - totalAmount);
printf("Total Amount (including tax): Rs%.2f\n", finalAmount);
}
}
else if (choice == 3) {
// Exit the program
printf("Thank you for using the Hotel Food Ordering System. Goodbye!\
n");
break;
}
else {
// Invalid input
printf("Invalid choice. Please try again.\n");
}
}

return 0;
}

You might also like