Hotel Managment System in C++

//Header Files..
#include <iostream>
#include <windows.h>
#include <string.h>
using namespace std;
// Structure for customer info..
struct customer_info{
 int days, roomrent, idcard;
 char name[100], address[100], phnumber[100];
}info[5];
//Structure for expences..
struct allexpences{
 int ebil, gbil, staffpay, repairs;
}expnc;
int available = 0;
// Displays the customer info..
void displayCustomer(int index){
 cout << "\n\tCustomer Name :   " << info[index].name << endl;
 cout << "\tCustomer Address :   " << info[index].address << endl;
 cout << "\tCustomer Phone Number :   " << info[index].phnumber << endl;
 cout << "\tCustomer ID :   " << info[index].idcard << endl;
 cout << "\tCustomer Room Rent :   " << info[index].roomrent << endl;
 cout << "\tCustomer's Staying Days :   " << info[index].days << endl;
}
// Display MENU...
void displayMenu(){
 system("color F0");
 cout << "\t========================================" << endl;
 cout << "\tHotel Management System BY Bilal & Group" << endl;
 cout << "\t========================================" << endl;
 cout << "\t1.Reserve Room" << endl;
 cout << "\t2.Check Customer Data" << endl;
 cout << "\t3.Check Stats" << endl;
 cout << "\t4.Checkout Customer" << endl;
 cout << "\t5.Add Expences" << endl;
 cout << "\t0.EXIT" << endl;
 cout << "\tYour Choice : ";
}
//Display the Statistics..
void statistics(int size){
 int totalexpences = 0, totalincome = 0;
 totalexpences = expnc.ebil + expnc.gbil + expnc.repairs + expnc.staffpay;
 for (int i = 0; i < size; i++)
 {
  totalincome = totalincome + info[i].roomrent;
 }
 cout << "\tTotal Expences = " << totalexpences << endl;
 cout << "\tTotal Income = " << totalincome << endl;
 if (totalincome > totalexpences)
 {
  cout << "\tYou are going in Profit of Rs: " << totalincome - totalexpences << endl;
 }
 else if (totalincome < totalexpences)
 {
  cout << "\tYour goin in Loss of Rs: " << totalexpences - totalincome << endl;
 }
 else
 {
  cout << "\tNo Profit No Loss !" << endl;
 }
}
// Customer Data Search Function..
void searchcustomer(int id)
{
 bool found = false;
 int index = 0;
 for (int i = 0; i < 5; i++)
 {
  if (id == info[i].idcard)
  {
   found = true;
   index = i;
   break;
  }
 }
 if (found){
  displayCustomer(index);
 }
 else {
  system("CLS");
  cout << "\n\n\n\n\n\n\n\n\n\n\t\t\t\tCustomer not Found !" << endl;
 }
}
//Delete Customer..
void deletecustomers(int id){
 bool found = false;
 int index = 0;
 for (int i = 0; i < 5; i++)
 {
  if (id == info[i].idcard)
  {
   found = true;
   index = i;
   break;
  }
 }
 if (found){
  for (int i = index; i < available; i++)
  {
   info[i] = info[i + 1];
  }
  available--;
  cout << "\n\n\n\n\n\n\n\n\n\n\t\t\t\tCustomer Deleted !" << endl;
 }
 else {
  system("CLS");
  cout << "\n\n\n\n\n\n\n\n\n\n\t\t\t\tCustomer Doesnot Exist !" << endl;
 }
}
//Main..
int main(){
 char choice;
 displayMenu();
 cin >> choice;
 switch (choice){
 case '0':
  system("CLS");
  cout << "\n\n\n\n\n\n\n\n\n\n\t\t\t\tBYE HAVE A GOOD DAY !" << endl;
  Sleep(2000);
  exit(0);
  break;
 case '1':
  if (available<5){
   system("CLS");
   cout << "\t=================" << endl;
   cout << "\tReservation Menu" << endl;
   cout << "\t=================" << endl;
   cout << "\tName: ";
   cin.ignore();
   cin.getline(info[available].name, 100);
   cout << "\tAddress: ";
   cin.getline(info[available].address, 100);
   cout << "\tContact No: ";
   cin.getline(info[available].phnumber, 100);
   cout << "\tID Card No: ";
   cin >> info[available].idcard;
   cout << "\tRoom Rent: ";
   cin >> info[available].roomrent;
   cout << "\tDay Stay's: ";
   cin >> info[available].days;
   system("CLS");
   cout << "\n\n\n\n\n\n\n\n\n\n\t\t\t\tCustomer Added !" << endl;
   available++;
   Sleep(3000);
   system("CLS");
   main();
  }
  else
  {
   system("CLS");
   cout << "\n\n\n\n\n\n\n\n\n\n\t\t\t\tHotel is Full !" << endl;
   Sleep(3000);
   system("CLS");
   main();
  }
  break;
 case '2':
  int id;
  system("CLS");
  cout << "\t==================" << endl;
  cout << "\tCustomer Data Menu" << endl;
  cout << "\t==================" << endl;
  cout << "\tEnter Customer ID Card Number: ";
  cin >> id;
  searchcustomer(id);
  Sleep(10000);
  system("CLS");
  main();
  break;
 case '3':
  system("CLS");
  cout << "\t==========" << endl;
  cout << "\tStats Menu" << endl;
  cout << "\t==========" << endl;
  statistics(available);
  Sleep(7000);
  system("CLS");
  main();
  break;
 case '4':
  system("CLS");
  cout << "\t=================" << endl;
  cout << "\tCheckout Menu" << endl;
  cout << "\t=================" << endl;
  cout << "\tID Card Number: ";
  cin >> id;
  system("CLS");
  deletecustomers(id);
  Sleep(3000);
  system("CLS");
  main();
  break;
 case '5':
  system("CLS");
  cout << "\t==============" << endl;
  cout << "\tExpences Menu" << endl;
  cout << "\t==============" << endl;
  cout << "\tElectricity Bill: ";
  cin >> expnc.ebil;
  cout << "\tGas Bill: ";
  cin >> expnc.gbil;
  cout << "\tTotal Staff Pay: ";
  cin >> expnc.staffpay;
  cout << "\tExpences on Maintenance: ";
  cin >> expnc.repairs;
  system("CLS");
  cout << "\n\n\n\n\n\n\n\n\n\n\t\t\t\tExpences Added!" << endl;
  Sleep(3000);
  system("CLS");
  main();
  break;
 default:
  system("cls");
  system("color 40");
  cout << "\n\n\n\n\n\n\n\n\n\n\t\t\t\tInvalid Input!" << endl;
  Sleep(1000);
  system("color F0");
  system("cls");
  main();
 }
 return 0;
}

No comments:

Post a Comment