Bus Ticket Reservation System Project in C++.
Bus Ticket Reservation System Project in C++ have the following functionalities.
Functionalities
- Enter Bus No.
- departure From.
- Select To city.
- Departure To city.
- Total seats:
- Bus Information Added.
- Total buses available.
- Total seat available.
- Enter Passenger’s Name.
- Number of seats.
- Limit Exceed…Please re-enter.
- Your purchase is completed.
- Show ticket details.
Following concepts are used in this project.
Variable, Variables declaration and initialization, data types, arrays, user define functions, classes, constructor, constructor overloading, destructor, for loop, if else statement, switch statement etc.
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 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
#include<iostream> using namespace std; int r=0,p=0,k=20; float TotalSale=0; class bus{ char PessengerName[99]; char deprt[9]; char from[9]; char to[9]; char arriva[9]; int T4tutorials_Total_Seats, T4tutorials_Total_Fare; int BusNo, T4tutorials_Departure_Timing, s; public: void T4tutorials_Bus_Registration(); void show(); void book(); void T4tutorialsExit(); }b[8]; void bus::T4tutorials_Bus_Registration(void) { cout.setf(ios::right,ios::adjustfield); cout.width(15); cout<<"\nEnter Bus No:"; cin>>BusNo; cout.setf(ios::right,ios::adjustfield); cout.width(15); cout<<"\nFrom: "; cin>>from; cout.setf(ios::right,ios::adjustfield); cout.width(15); cout<<"\nTo: "; cin>>to; cout.setf(ios::right,ios::adjustfield); cout.width(15); cout<<"\nDeparture: "; cin>>T4tutorials_Departure_Timing; cout.setf(ios::right,ios::adjustfield); cout.width(15); cout<<"\nTotal seats: "; cin>>T4tutorials_Total_Seats; p++; cout<<"\n"; cout<<"Bus Information Added!!\n"; system("PAUSE"); system("CLS"); } void bus::show(void) { cout<<"\nTotal bus available:"<<endl; for(int i=0;i<p;i++) { cout.setf(ios::right,ios::adjustfield); cout.width(15); cout<<"Bus No: "; cout<<b[i].BusNo<<endl; cout.setf(ios::right,ios::adjustfield); cout.width(15); cout<<"From: "; cout<<b[i].from<<endl; cout.setf(ios::right,ios::adjustfield); cout.width(15); cout<<"To: "; cout<<b[i].to<<endl; cout.setf(ios::right,ios::adjustfield); cout.width(15); cout<<"Departure: "; cout<<b[i].T4tutorials_Departure_Timing<<" O'clock"<<endl; cout.setf(ios::right,ios::adjustfield); cout.width(15); cout<<"Seats: "; cout<<b[i].T4tutorials_Total_Seats<<endl<<endl<<endl; } system("PAUSE"); system("CLS"); } void bus::book(void) { int number; float T4tutorials_Total_Fare; cout<<"\nEnter Bus No: "; cin>>number; int n; for(n=0;n<p;n++) { if(b[n].BusNo==number) { if(b[n].T4tutorials_Total_Seats<=0) { cout<<"\tSORRY!"<<endl<<"\tNo Seat Available\t"; } else { cout<<endl<<"Total seat available: "<<b[n].T4tutorials_Total_Seats; cout<<endl<<"Enter Passenger's Name: "; cin>>PessengerName; cout<<endl<<"Number of seats: "; cin>>s; while((b[n].T4tutorials_Total_Seats=b[n].T4tutorials_Total_Seats-s)<0) {cout<<endl<<"Limit Exceed...Please re-enter "; b[n].T4tutorials_Total_Seats=b[n].T4tutorials_Total_Seats+s; cin>>s; } cout<<endl<<"Your purchase is completed"<<endl; cout.setf(ios::right,ios::adjustfield); cout.width(30); cout<<"Bus No: "; cout<<b[n].BusNo<<endl; cout.setf(ios::right,ios::adjustfield); cout.width(30); cout<<"From: "; cout<<b[n].from<<" to "<<b[n].to<<endl; cout.setf(ios::right,ios::adjustfield); cout.width(30); cout<<"Departure: "; cout<<b[n].T4tutorials_Departure_Timing<<" O'clock"<<endl; cout.setf(ios::right,ios::adjustfield); cout.width(30); cout<<"Total seat: "; cout<<s<<endl; T4tutorials_Total_Fare=30*s; T4tutorials_Total_Fare=T4tutorials_Total_Fare+(T4tutorials_Total_Fare*.12); TotalSale=TotalSale+T4tutorials_Total_Fare; cout.setf(ios::right,ios::adjustfield); cout.width(30); cout<<"Total T4tutorials_Total_Fare(with 12%vat): "; cout.setf(ios::showpoint); cout.precision(3); cout.setf(ios::fixed,ios::floatfield); cout.width(8); cout<<T4tutorials_Total_Fare<<endl; cout.setf(ios::right,ios::adjustfield); cout.width(30); cout<<"Thank You!!!"<<endl<<endl; } } } system("PAUSE"); system("CLS"); } int main() { int w,g=1; while(g){ cout<<"***************"<<endl; cout<<"\t\t\t\tBus Ticketing System\n"; cout<<"*************** "<<endl; cout<<" T4tutorials_Bus_Registration\n\t\t\t 2 :: List Available Bus\n\t\t\t 3 => Book Tickets\n\t\t\t 4 => T4tutorialsExit"; cout<<"\n\n\t\t Enter your choice: "; cin>>w; switch(w){ case 1: b[p].T4tutorials_Bus_Registration(); break; case 2: b[0].show(); break; case 3: b[p].book(); break; case 4: { g=0; cout<<endl<<"Total Sales:"<<TotalSale<<endl; break; } } } return 0; } |
Output
Download
Bus Ticket Reservation System Project in C++