Question

need help with c++ project:

For the project. Create a c++ program about bus booking and ticketing system that - This system also needs you to key in your

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include<iostream>
using namespace std;

int r=0,p=0,k=20;
float allsell=0;

class bus{

char arriva[9],deprt[9],from[9],to[9],pname[99];
int busn,dtym,tseat,fair,s;
public:
   void install();
   void show();
   void book();
   void exit();


}b[8];

void bus::install(void)
{
   cout.setf(ios::right,ios::adjustfield);
   cout.width(15);
cout<<"Enter Bus No:";
cin>>busn;
   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>>dtym;
   cout.setf(ios::right,ios::adjustfield);
   cout.width(15);
cout<<"\nTotal seats: ";
cin>>tseat;

p++;
cout<<"\n";
cout<<"Bus Information Added!!\n";
system("PAUSE");
system("CLS");

}

void bus::show(void)
{
   cout<<"total 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].busn<<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].dtym<<" O'clock"<<endl;
           cout.setf(ios::right,ios::adjustfield);
           cout.width(15);
           cout<<"Seats: ";
           cout<<b[i].tseat<<endl<<endl<<endl;

       }
       system("PAUSE");
       system("CLS");
}


void bus::book(void)
{
int number;
float fair;
   cout<<"Enter Bus No: ";
   cin>>number;
   int n;
for(n=0;n<p;n++)
{
   if(b[n].busn==number)
   {
       if(b[n].tseat<=0)
       {
       cout<<"\tSORRY!"<<endl<<"\tNo Seat Available\t";
       }
       else
       {
       cout<<endl<<"Total seat available: "<<b[n].tseat;
       cout<<endl<<"Enter Passenger's Name: ";
       cin>>pname;
       cout<<endl<<"Number of seats: ";
       cin>>s;
       while((b[n].tseat=b[n].tseat-s)<0)
           {cout<<endl<<"Limit Exceed...Please re-enter ";
           b[n].tseat=b[n].tseat+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].busn<<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].dtym<<" O'clock"<<endl;
cout.setf(ios::right,ios::adjustfield);
   cout.width(30);
cout<<"Total seat: ";
cout<<s<<endl;
fair=300*s;
fair=fair+(fair*.7);
allsell=allsell+fair;
cout.setf(ios::right,ios::adjustfield);
   cout.width(30);
cout<<"Total Fair(with 7%vat): ";

cout.setf(ios::showpoint);
cout.precision(3);
cout.setf(ios::fixed,ios::floatfield);
cout.width(8);
cout<<fair<<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<<"\n\n\t\t\t\t==================================================="<<endl;
cout<<"\t\t\t\t\t\tBus Ticketing System\n";
cout<<"\t\t\t\t==================================================="<<endl;

cout<<"\t\t\t\t\t 1 => Install\n\t\t\t\t\t 2 => List Available Bus\n\t\t\t\t\t 3 => Book Tickets\n\t\t\t\t\t 4 => Exit";
cout<<"\n\n\t\t\t\t\t Enter your choice: ";
cin>>w;
switch(w){
case 1:
   b[p].install();//fn1353p

break;
case 2:
   b[0].show();
break;
case 3:
   b[p].book();

break;
case 4:
   {
g=0;

cout<<endl<<"Total Sales:"<<allsell<<endl<<"******Thank You******"<<endl;
cout<<"Brought To You By code-projects.org";
break;
   }
}
}
return 0;
}

Add a comment
Know the answer?
Add Answer to:
need help with c++ project: For the project. Create a c++ program about bus booking and...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Program is in C++, program is called airplane reservation. It is suppose to display a screen...

    Program is in C++, program is called airplane reservation. It is suppose to display a screen of seating chart in the format 1 A B C D E F through 10. I had a hard time giving the seats a letter value. It displays a correct screen but when I reserve a new seat the string seats[][] doesn't update to having a X for that seat. Also there is a file for the struct called systemUser.txt it has 4 users...

  • I need help in C++ . Project 3 – Parking Deck Ticketing System Objectives: Use if,...

    I need help in C++ . Project 3 – Parking Deck Ticketing System Objectives: Use if, switch, and loop statements to solve a problem. Use input and output statements to model a real world application Incorporate functions to divide the program into smaller segments Instructions: Your task is to write a program that simulates a parking meter within the parking deck. The program will start by reading in the time a car arrives in the parking deck. It will then...

  • Hello I need help with this program. Should programmed in C! Program 2: Sorting with Pointers...

    Hello I need help with this program. Should programmed in C! Program 2: Sorting with Pointers Sometimes we're given an array of data that we need to be able to view in sorted order while leaving the original order unchanged. In such cases we could sort the data set, but then we would lose the information contained in the original order. We need a better solution. One solution might be to create a duplicate of the data set, perhaps make...

  • C++ Project Overview The 18th season of the reality series Hell's Kitchen began airing on Sep 28th, 2018 on Fox. Suppose you are working for the boss, Chef Gordon Ramsay, your job is to create an...

    C++ Project Overview The 18th season of the reality series Hell's Kitchen began airing on Sep 28th, 2018 on Fox. Suppose you are working for the boss, Chef Gordon Ramsay, your job is to create an efficient system that generates a menu. Since in Hell's Kitchen, menu changes every day, your system should easily add items to the menu. Therefore, dynamically allocated arrays would be an excellent solution. The Dish Class (Header File) You need to create a struct called...

  • Please!!! need help asap!!!! write a C++program to analyze a small subset of the data that...

    Please!!! need help asap!!!! write a C++program to analyze a small subset of the data that has been collected. See file universities.txt .Use precisely seven parallel arrays: one for name of university, one for state, one for city, one for yearly tuition, one for enrollment, one for average freshman retention, and one for the percent of students who graduate with in six years. Note that the percentage of student accepted is not stored.An output file is opened in main() and...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT