Future of world with technology grow, thrive, empower yourself, one step at a time. Sucess unlocked.
The journey of self-motivation and personal growth is a lifelong path, filled with twists and turns, triumphs and setbacks. By embracing this journey, we can develop the skills, confidence, and resilience needed to achieve our goals and live a fulfilling life. I hope that my insights and experiences will inspire and motivate you to embark on your own journey of self-discovery and growth. Join me as I share insights, experiences, and practical tips on living a fulfilling life.
Thursday, March 13, 2025
C++ program for a hospital
C++ program for a restaurant
Here's a simple C++ program for a restaurant:
#include <iostream>
#include <string>
using namespace std;
class Restaurant {
private:
string itemName[10];
int itemPrice[10];
int itemQuantity[10];
int numberOfItems;
public:
void addItem() {
cout << "Enter item name: ";
cin.ignore();
getline(cin, itemName[numberOfItems]);
cout << "Enter item price: ";
cin >> itemPrice[numberOfItems];
cout << "Enter item quantity: ";
cin >> itemQuantity[numberOfItems];
numberOfItems++;
}
void displayMenu() {
cout << "\nRestaurant Menu\n";
for (int i = 0; i < numberOfItems; i++) {
cout << (i + 1) << ". " << itemName[i] << " - $" << itemPrice[i] << " (" << itemQuantity[i] << " available)\n";
}
}
void placeOrder() {
int choice, quantity;
cout << "Enter the item number to order: ";
cin >> choice;
cout << "Enter the quantity to order: ";
cin >> quantity;
if (choice > 0 && choice <= numberOfItems && quantity <= itemQuantity[choice - 1]) {
cout << "Order placed successfully!\n";
itemQuantity[choice - 1] -= quantity;
} else {
cout << "Invalid choice or insufficient quantity.\n";
}
}
void displayOrderSummary() {
cout << "\nOrder Summary\n";
for (int i = 0; i < numberOfItems; i++) {
if (itemQuantity[i] < itemQuantity[i]) {
cout << itemName[i] << " x " << (itemQuantity[i] - itemQuantity[i]) << "\n";
}
}
}
};
int main() {
Restaurant restaurant;
int choice;
restaurant.numberOfItems = 0;
while (true) {
cout << "\nRestaurant Management System\n";
cout << "1. Add item to menu\n";
cout << "2. Display menu\n";
cout << "3. Place order\n";
cout << "4. Display order summary\n";
cout << "5. Exit\n";
cout << "Enter your choice: ";
cin >> choice;
switch (choice) {
case 1:
restaurant.addItem();
break;
case 2:
restaurant.displayMenu();
break;
case 3:
restaurant.placeOrder();
break;
case 4:
restaurant.displayOrderSummary();
break;
case 5:
return 0;
default:
cout << "Invalid choice. Please try again.\n";
}
}
return 0;
}
*Example Output:*
Restaurant Management System
1. Add item to menu
2. Display menu
3. Place order
4. Display order summary
5. Exit
Enter your choice: 1
Enter item name: Burger
Enter item price: 10
Enter item quantity: 5
Restaurant Management System
1. Add item to menu
2. Display menu
3. Place order
4. Display order summary
5. Exit
Enter your choice: 2
Restaurant Menu
1. Burger - $10 (5 available)
Restaurant Management System
1. Add item to menu
2. Display menu
3. Place order
4. Display order summary
5. Exit
Enter your choice: 3
Enter the item number to order: 1
Enter the quantity to order: 2
Order placed successfully!
Restaurant Management System
1. Add item to menu
2. Display menu
3. Place order
4. Display order summary
5. Exit
Enter your choice: 4
Order Summary
Burger x 2
This program defines a `Restaurant` class with private member variables for menu items, prices, and quantities. The class includes public methods for adding items to the menu, displaying the menu, placing orders, and displaying order summaries.
In the `main()` function, a `Restaurant` object is created, and a simple text-based menu is displayed. The user can interact with the program by choosing options to add items, display the menu, place orders, or display order summaries.
Featured posts
स्मार्ट इन्वेस्टिंग फॉर बिगिनर्स:
स्मार्ट इन्वेस्टिंग फॉर बिगिनर्स: पैसिव इनकम कमाने का आसान रास्ता"। इसमें मैंने बताया है कि कैसे छोटी रकम से शुरुआत करके, म्यूचुअल फ...
Popular posts
-
Here's a more comprehensive list of names for God in various languages: Indo-European Languages 1. *Sanskrit*: Brahma (ब्रह्म), Vishnu...

