1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
|
#include <iostream>
#include <fstream>
#include <stdlib.h>
#include <iomanip>
#include <string>
using namespace std;
struct reserve
{
string name;
string date;
string time;
string operation;
};
int main()
{
reserve res;
fstream myfile;
char choice;
myfile.open("Reservation.txt",ios::in|ios::out|ios::app);
choices:
cout<<"\t\t\tReservation"<<endl;
cout<<"Choice the letter of your choice:"<<endl;
cout<<"[A]. View Reservation\n[B]. Add Reservation\n[C]. Remove Reservation\n[D]. Exit Program"<<endl;
cout<<"\nChoice:";
cin>>choice;
cin.ignore(10000, '\n');
if (choice=='A'||choice=='a')
{
system("cls");
cout<<"\n\n\t\t\t\tLIST OF RESERVATION";
string output;
myfile.seekg(0,ios::beg);
cout<<endl<<endl;
cout<<left<<setw(25)<<"NAME";
cout<<left<<setw(25)<<"DATE";
cout<<left<<setw(20)<<"TIME";
cout<<left<<setw(20)<<"OPERATION";
cout<<"\n";
while (getline(myfile, output))
{
cout<<endl;
cout<<left<<setw(25)<<output;
std::getline(myfile, output);
cout<<left<<setw(25)<<output;
std::getline(myfile, output);
cout<<left<<setw(20)<< output;
std::getline(myfile, output);
cout<<left<<setw(20) << output;
cout<<endl;
}
cout<<endl<<endl;
cout<<"\t\t\t\t******************"<<endl;
system("pause");
system("cls");
cout<<"\n\n\n \t\t\t\tT H A N K Y O U! \n\n\n"<<endl;
system("pause");
}
else if(choice=='B'||choice=='b')
{
system("cls");
cout<<"\n\t\t\t\tADD A RESERVATION\n"<<endl;
cout<<"\n\tEnter the name:";
getline(cin,res.name);
cout<<"\n\tEnter the date:";
getline(cin,res.date);
cout<<"\n\tEnter the time:";
getline(cin,res.time);
cout<<"\n\tEnter the operation:";
getline(cin,res.operation);
myfile<<res.name<<"\n"<<res.date<<"\n"<<res.time<<"\n"<<res.operation<<"\n";
system("cls");
cout<<"\n\n\n\t\t\t\tS U C C E S S F U L L Y A D D E D\n\n\n"<<endl;
system("pause");
system("cls");
goto choices;
}
else if(choice=='C'||choice=='c')
{
string x,del;
cout<<"Remove:";
cin>>x;
myfile.seekg(0,ios::beg);
int ctr =1;
while(getline(myfile,del))
{
if (ctr==1)
{
if(del==x)
{
cout<<del;
getline(myfile,del);
cout<<del;
getline(myfile,del);
cout<<del;
getline(myfile,del);
ctr=0;
}else
{
ctr++;
}
ctr++;
}
}
}
else if(choice=='D'||choice=='d')
{
return 0;
}
else
{
system("cls");
goto choices;
}
}
|