0% found this document useful (0 votes)
23 views8 pages

Miniproject

The document defines classes and functions for a hotel management system. It includes structs to store guest and menu item details. Functions allow guests to place orders from the menu, view their orders, and calculate the total bill and discounts. The program stores guest information, displays the menu for different meal types, and handles ordering and billing operations.

Uploaded by

shantanujoshi445
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)
23 views8 pages

Miniproject

The document defines classes and functions for a hotel management system. It includes structs to store guest and menu item details. Functions allow guests to place orders from the menu, view their orders, and calculate the total bill and discounts. The program stores guest information, displays the menu for different meal types, and handles ordering and billing operations.

Uploaded by

shantanujoshi445
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/ 8

#include <iostream>

#include <string>
using namespace std;

const int maxsize = 50;


const int maxItems = 10;
const int maxGuests = 5; // Adjust the maximum number of guests as needed

struct node {
string name, phoneno, itemname;
int priceOfItem,roomid;
node* link;
};

class Stack {
node* head;

public:
Stack() {
head = NULL;
}

void pricelist(string itemName, int price);


int getPrice(string itemName);
void displayPriceList();
int totalbill(const string* orderedItems, int numOrderedItems,const int *
quantity);
void delitem();
};

class Guest {
node* head;
string orderedItems[maxItems];
int numOrderedItems;
int quantity[maxsize];
int roomid[maxsize];

public:

Guest() {
head = NULL;
numOrderedItems = 0;
for(int i=0;i<maxsize;i++)
{
roomid[i]=i+1;
}

int isempty();
void insert();

void display();
int search();
int placeorder();
void displayOrderedItems() const;

const string* getOrderedItems() const {


return orderedItems;
}

int getNumOrderedItems() const {


return numOrderedItems;
}
const int * getNoofquantity() const {
return quantity;
}
const int * getroomno() const {
return roomid;
}
};

void Stack::pricelist(string itemName, int price) {


node* nn = new node;
if (nn == NULL) {
cout << "Memory is full";
return;
}
nn->itemname = itemName;
nn->priceOfItem = price;
nn->link = head;
head = nn;
}

int Stack::getPrice(string itemName) {


node* temp = head;
while (temp != NULL) {
if (temp->itemname == itemName) {
return temp->priceOfItem;
}
temp = temp->link;
}
return -1; // Item not found
}

void Stack::delitem(){
if(head==NULL){
cout<<"No itemm is placed yet"<<endl;
}

node*temp=head;
head=temp->link;

delete temp;

}
void Stack::displayPriceList() {
node* temp = head;
cout << "Price List:" << endl;
while (temp != NULL) {
cout << temp->itemname << ": " << temp->priceOfItem << " Rs" << endl;
temp = temp->link;
}
}
int Stack::totalbill(const string* orderedItems, int numOrderedItems,const int
*quantity) {
int totalBill = 0;
Guest g;

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


int itemPrice = getPrice(orderedItems[i]);
if (itemPrice != -1) {
totalBill =totalBill+ (itemPrice*quantity[i]);
}
else {
// Handle the case where the item is not found in the price list.
cout << "Error: Price not found for item " << orderedItems[i] << endl;
}
}

return totalBill;
}

int Guest::placeorder() {
char addMore;
do {
if (numOrderedItems < maxItems) {
cout << "Enter the item you want to order:";
cin >> orderedItems[numOrderedItems];
cout<<"Enter Quantity of an item: ";
cin>>quantity[numOrderedItems];
numOrderedItems++;
}
else {
cout << "You have reached the maximum number of items allowed in an
order." << endl;
break;
}

cout << "Do you want to add more items? (y/n): ";
cin >> addMore;

} while (addMore == 'Y' || addMore == 'y');

return numOrderedItems;
}

void Guest::displayOrderedItems() const {


if (numOrderedItems == 0) {
cout << "No orders placed yet." << endl;
}
else {
cout << "Ordered Items:" << endl;
for (int i = 0; i < numOrderedItems; i++) {
cout << i + 1 << ". " << orderedItems[i] << endl;
}
}
}

void Guest::insert() {
int noofdays;
node* nn = new node;
if (nn == NULL) {
cout << "Memory is full";
return;
}

cout << "Enter your name: ";


cin >> nn->name;

do {
cout << "Enter phone number: ";
cin >> nn->phoneno;
int length = nn->phoneno.length();

if (length != 10) {
cout << "Enter a valid 10-digit phone number." << endl;

}
} while (nn->phoneno.length() != 10);

cout << "Please Enter the number of days you require the room:";
cin >> noofdays;
nn->link = NULL;

if (head == NULL) {
head = nn;
}
else {
node* temp = head;
while (temp->link != NULL) {
temp = temp->link;
}
temp->link = nn;
}

cout << "Thank you! Let's check if the room is available or not." << endl;
}

// void check(Guest guests[], int& numGuests) {


// int roomid;
// cout << "Enter room id to check availability: ";
// cin >> roomid;

// bool roomAvailable = true;


// for (int i = 0; i < numGuests; i++) {
// if (guests[i].roomid == roomid) {
// roomAvailable = false;
// break;
// }
// }

// if (roomAvailable) {
// cout << "Room " << roomid << " is available." << endl;
// }
// else {
// cout << "Room " << roomid << " is not available." << endl;
// }
// }

int Discountonbill(int totalBill)


{
int finalbill=0,discount;
if(totalBill>=500)
{
discount=totalBill*0.5;
cout << "Congratulations! You get a 50% discount on your total
bill."<<endl;
}
else if(totalBill>=300)
{
discount=totalBill*0.3;
cout << "Congratulations! You get a 30% discount on your total
bill."<<endl;

}
else if(totalBill>=200){
discount=totalBill*0.2;
cout << "Congratulations! You get a 20% discount on your total bill."<<endl;

}
else{
discount=0;
}
finalbill=totalBill-discount;

return finalbill;

// void Stack:: addfront(int n){


// node *nn;
// nn=new node;
// if(nn==NULL){
// cout<<"MEmory is full";
// }

// nn->roomid=n;
// nn->link=head;
// head=nn;

// }

void showoffers()
{
cout << "------- SPECIAL OFFERS -------" <<endl;
cout << "1. Purchase above 500 Rs and get a 50% discount!" <<endl;
cout << "2. Purchase between 300 Rs and 499 Rs and get a 30% discount!" <<endl;
cout << "3. Purchase between 200 Rs and 299 Rs and get a 20% discount!" <<endl;
cout << "--------------------------------" <<endl;
}

int main() {
Guest guests[maxGuests];
Stack s1;
int numGuests = 0;

cout << "********WELCOME TO OUR HOTEL**********" << endl;

do {
cout << "Please Enter your Details for Guest " << numGuests + 1 << endl;
guests[numGuests].insert();
const int* roomid = guests[numGuests].getroomno();
cout<<"YOUR ROOM-ID IS::-"<<roomid[numGuests]<<endl;

cout<<"* OFFERS ON MENU: *"<<endl;


showoffers();

int ch;
cout << "You are looking for which type of meal" << endl;
cout << "Enter 1 for breakfast" << endl;
cout << "Enter 2 for lunch or dinner" << endl;
cout << "Enter 3 for any cold-drink or ice cream" << endl;
cout << "Enter 4 for fast-food" << endl;
cout << "Enter 5 for Indian-Sweets" << endl;
cin >> ch;

switch (ch) {
case 1:
s1.pricelist("Poha", 30);
s1.pricelist("Idli-Sambar", 30);
s1.pricelist("Masala-Dosa", 40);
s1.pricelist("Uttapa", 40);
s1.pricelist("Wada-Sambar", 30);
s1.pricelist("Khichdi", 30);
s1.pricelist("Misal-Paw", 50);
s1.pricelist("Plane-Dosa", 50);
s1.pricelist("Fruit-Plate", 30);
cout << "**********MENU***********" << endl;
cout << "Available Items In Breakfast:";
s1.displayPriceList();

break;
case 2:
s1.pricelist("Roti", 20);
s1.pricelist("Tandur", 30);
s1.pricelist("Mix-Veg", 140);
s1.pricelist("Veg-Maratha", 140);
s1.pricelist("Baingan-Masala", 130);
s1.pricelist("Rice-Plate", 80);
s1.pricelist("Shev-Bhaji", 140);
s1.pricelist("Paneer-Masala", 160);
s1.pricelist("Aalu-Matar", 150);
cout << "**********MENU***********" << endl;
cout << "Available Items in Lunch/Dinner are:" << endl;
s1.displayPriceList();

break;
case 3:
s1.pricelist("Tea", 10);
s1.pricelist("Thumbs-Up", 20);
s1.pricelist("Orange-Juice", 40);
s1.pricelist("Apple-Juice", 40);
s1.pricelist("Pineapple-Juice", 30);
s1.pricelist("Mango-Juice", 40);
s1.pricelist("cold-Coffe", 30);
s1.pricelist("Hot-Coffe", 20);
s1.pricelist("Slice", 20);
cout << "**********MENU***********" << endl;
cout << "Available Drinks are:" << endl;
s1.displayPriceList();

break;
case 4:
s1.pricelist("Pizza", 200);
s1.pricelist("Burger", 90);
s1.pricelist("Sandwich", 80);
s1.pricelist("Aalu-Paratha", 50);
s1.pricelist("manchuriyan", 50);
s1.pricelist("Momos", 40);
s1.pricelist("chinese-Bhel", 40);
s1.pricelist("Panipuri", 20);
s1.pricelist("SPDP", 60);
cout << "**********MENU***********" << endl;
cout << "Available Items in Snacks are:" << endl;
s1.displayPriceList();

break;
case 5:
s1.pricelist("Rasgulla", 150);
s1.pricelist("Gulab-Jamun", 80);
s1.pricelist("besan-Barfi", 150);
s1.pricelist("Basundi", 190);
s1.pricelist("Balushahi", 80);
s1.pricelist("Rasmalai", 200);
s1.pricelist("Carrot-Halwa", 15);
cout << "Available Items in Dessert are:" << endl;
s1.displayPriceList();
break;

default:
cout << "SORRY! Not available" << endl;
}

guests[numGuests].placeorder();
cout << "Your ordered items are:" << endl;
guests[numGuests].displayOrderedItems();
const string* orderedItems = guests[numGuests].getOrderedItems();
int numOrderedItems = guests[numGuests].getNumOrderedItems();
const int* Quantity = guests[numGuests].getNoofquantity();

int totalBill = s1.totalbill(orderedItems, numOrderedItems,Quantity);


cout << "Total Bill: " << totalBill << " Rs" << endl;
int discountBILL=Discountonbill(totalBill);

cout << "After discount your Bill: " << discountBILL<< " Rs" << endl;
cout << "THANK YOU!" << endl;

char addMoreGuest;
cout << "Do you want to add more guests? (y/n): ";
cin >> addMoreGuest;

if (addMoreGuest != 'Y' && addMoreGuest != 'y') {


break;
}
numGuests++;

//i<9 -Because available Item are 9 in our hotel


for(int i=0;i<9;i++){
s1.delitem();
}

} while (numGuests < maxGuests);

return 0;
}

You might also like