Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can help me create the flowchart based on this coding? thankyou :) C++ #include #include #include #include #include using namespace std; static int p =

Can help me create the flowchart based on this coding? thankyou :)

C++

#include

#include

#include

#include

#include

using namespace std;

static int p = 0;

class a

{

char busn[5], driver[10], arrival[5], depart[5], from[10], to[10], seat[8][4][10];

public:

void install();

void allotment();

void empty();

void show();

void avail();

void position(int i);

}

bus[10];

void vline(char ch)

{

for (int i=80;i>0;i--)

cout<

}

void a::install()

{

cout<<"Enter bus no: ";

cin>>bus[p].busn;

cout<<" Enter Driver's name: ";

cin>>bus[p].driver;

cout<<" Arrival time: ";

cin>>bus[p].arrival;

cout<<" Departure: ";

cin>>bus[p].depart;

cout<<" From: \t\t\t";

cin>>bus[p].from;

cout<<" To: \t\t\t";

cin>>bus[p].to;

bus[p].empty();

p++;

}

void a::allotment()

{

int seat;

char number[5];

top:

cout<<"Bus no: ";

cin>>number;

int n;

for(n=0;n<=p;n++)

{

if(strcmp(bus[n].busn, number)==0)

break;

}

while(n<=p)

{

cout<<" Seat Number: ";

cin>>seat;

if(seat>32)

{

cout<<" There are only 32 seats available in this bus.";

}

else

{

if (strcmp(bus[n].seat[seat/4][(seat%4)-1], "Empty")==0)

{

cout<<"Enter passanger's name: ";

cin>>bus[n].seat[seat/4][(seat%4)-1];

break;

}

else

cout<<"The seat no. is already reserved. ";

}

}

if(n>p)

{

cout<<"Enter correct bus no. ";

goto top;

}

}

void a::empty()

{

for(int i=0; i<8;i++)

{

for(int j=0;j<4;j++)

{

strcpy(bus[p].seat[i][j], "Empty");

}

}

}

void a::show()

{

int n;

char number[5];

cout<<"Enter bus no: ";

cin>>number;

for(n=0;n<=p;n++)

{

if(strcmp(bus[n].busn, number)==0)

break;

}

while(n<=p)

{

vline('*');

cout<<"Bus no: \t"<

<<" Driver: \t"<

<

<<" From: \t\t"<

bus[n].to<<" ";

vline('*');

bus[0].position(n);

int a=1;

for (int i=0; i<8; i++)

{

for(int j=0;j<4;j++)

{

a++;

if(strcmp(bus[n].seat[i][j],"Empty")!=0)

cout<<" The seat no "<<(a-1)<<" is reserved for "<

}

}

break;

}

if(n>p)

cout<<"Enter correct bus no: ";

}

void a::position(int l)

{

int s=0;p=0;

for (int i =0; i<8;i++)

{

cout<<" ";

for (int j = 0;j<4; j++)

{

s++;

if(strcmp(bus[l].seat[i][j], "Empty")==0)

{

cout.width(5);

cout.fill(' ');

cout<

cout.width(10);

cout.fill(' ');

cout<

p++;

}

else

{

cout.width(5);

cout.fill(' ');

cout<

cout.width(10);

cout.fill(' ');

cout<

}

}

}

cout<<" There are "<

}

void a::avail()

{

for(int n=0;n

{

vline('*');

cout<<"Bus no: \t"<

<<"\t\tArrival time: \t"<

<

<

vline('*');

vline('_');

}

}

int main()

{

system("cls");

int w;

while(1)

{

//system("cls");

cout<<" ";

cout<<"\t\t\t1.Install \t\t\t"

<<"2.Reservation \t\t\t"

<<"3.Show \t\t\t"

<<"4.Buses Available. \t\t\t"

<<"5.Exit";

cout<<" \t\t\tEnter your choice:-> ";

cin>>w;

switch(w)

{

case 1: bus[p].install();

break;

case 2: bus[p].allotment();

break;

case 3: bus[0].show();

break;

case 4: bus[0].avail();

break;

case 5: exit(0);

}

}

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle 12c SQL

Authors: Joan Casteel

3rd edition

1305251032, 978-1305251038

More Books

Students also viewed these Databases questions

Question

1.5 Summarize HRM issues for small businesses.

Answered: 1 week ago

Question

Question May I set up a Keogh plan in addition to an IRA?

Answered: 1 week ago