#include <iostream>
#include <fstream>
#include <string>
using namespace std;
class Hotel {
public:
void mainMenu();
void bookRoom();
void viewCustomers();
void searchCustomer();
void checkOut();
};
void Ho[Link] {
int choice;
do {
cout << "\n========== Hotel Management System ==========\n";
cout << "1. Book a Room\n";
cout << "2. View All Customers\n";
cout << "3. Search Customer\n";
cout << "4. Check-Out\n";
cout << "5. Exit\n";
cout << "Enter your choice: ";
cin >> choice;
switch (choice) {
case 1:
bookRoom();
break;
case 2:
viewCustomers();
break;
case 3:
searchCustomer();
break;
case 4:
checkOut();
break;
case 5:
cout << "Exiting program...\n";
exit(0);
default:
cout << "Invalid choice. Try again.\n";
}
} while (true);
}
void Ho[Link] {
string name, phone;
int roomNo;
cout << "\nEnter Customer Name: ";
cin >> name;
cout << "Enter Room No: ";
cin >> roomNo;
cout << "Enter Phone Number: ";
cin >> phone;
ofstream outFile("[Link]", ios::app);
outFile << name << " " << roomNo << " " << phone << "\n";
[Link]();
cout << "Room booked successfully!\n";
}
void Ho[Link] {
string name, phone;
int roomNo;
ifstream inFile("[Link]");
cout << "\nList of Customers:\n";
cout << "Name\tRoom\tPhone\n";
cout << "----------------------------\n";
while (inFile >> name >> roomNo >> phone) {
cout << name << "\t" << roomNo << "\t" << phone << "\n";
}
[Link]();
}
void Ho[Link] {
string targetName, name, phone;
int roomNo;
bool found = false;
cout << "\nEnter customer name to search: ";
cin >> targetName;
ifstream inFile("[Link]");
while (inFile >> name >> roomNo >> phone) {
if (name == targetName) {
cout << "\nCustomer Found:\n";
cout << "Name: " << name << "\nRoom: " << roomNo << "\nPhone: " <<
phone << "\n";
found = true;
break;
}
}
if (!found) {
cout << "Customer not found.\n";
}
[Link]();
}
void Ho[Link] {
string targetName, name, phone;
int roomNo;
bool found = false;
cout << "\nEnter customer name to check-out: ";
cin >> targetName;
ifstream inFile("[Link]");
ofstream tempFile("[Link]");
while (inFile >> name >> roomNo >> phone) {
if (name == targetName) {
found = true;
cout << "Customer " << name << " has been checked out.\n";
} else {
tempFile << name << " " << roomNo << " " << phone << "\n";
}
}
[Link]();
[Link]();
remove("[Link]");
rename("[Link]", "[Link]");
if (!found) {
cout << "Customer not found.\n";
}
}
int main() {
Hotel h;
[Link]();
return 0;
}