Question: I need help writing a C++ class that should silumate a minor Bus system. The user should be able to input passenger information and then
I need help writing a C++ class that should silumate a minor Bus system. The user should be able to input passenger information and then simulate each passenger getting on and off the bus at specific stops and calculating any monetary amount they may have left after the trip. Here's the actual assignment description and what I have so far.
Note : The picture attached says Java, ignore this please this is a mistake on the instructors part, the code provided is in C++.


#include #include #include
using namespace std;
struct passenger{ passenger *next; string name; //Name of passenger int wallet; //Integer value for monetary amount in wallet string start; //The arrival stop for passenger string stop; //Departure stop for passenger }*head;
void Busroute{string start){ string Bus[5] = ["Union St", "Michigan Ave", "Soldier Field", "China Town", "IIT Campus"]; }
void Add_passenger(string name, int money, string start, string stop) { struct passenger *temp, *s; temp = new(struct passenger); //dynamically creating new passenger node if (temp == NULL){ //checks whether the memory is allocated or not coutname = name; //assigning the student information to created temp node temp->wallet = money; temp->start = start; temp->stop = stop; temp->next = NULL; } if(head == NULL)//Because head pointer is null then make temp node as head { head = temp; head->next = NULL; coutnext != NULL) //checking the next node is last or not { s = s->next; } temp->next = NULL; s->next = temp; cout
void Runbus(string start){ struct passenger*s; s = head; if (head == NULL) { cout
int main(int argc, char** argv) { int choice; int money; string name,start,stop; head = NULL; while(1) //while loop ,to add as much as data you want { cout
https://docs.google.com/document/d/1Ly2kWGs7mY8XCkrYKXrZtVnlzZEc7_6RGL_Cnrr9I1c/edit?usp=sharing
Class Bus: Ability to show or display route and all stops Ability to let a passenger get on the bus and charge a fare based on how many stops. Ability to let a passenger get off the bus Ability to keep track the number of passengers on the bus Ability to keep track each individual passenger on the bus Ability to keep track of the amount fares collected all time There is a maximum limit of capcity for the bus There is a maximum limit of stops on the route Class Passenger: Name of the passenger amount of money in his/her wallet (use integer to keep it simple) which stop to get on the bus which stop to get off the bus the java main function should have the following functions: create a bus object allow the user to create a number of passengers and specify the specifc details for each passenger, e. name, money amount, stop to get on and stop to get off Simulate and print out the activities alone the bus route as ustrated in the following diagram. and also in the screen shots. Class Bus: Ability to show or display route and all stops Ability to let a passenger get on the bus and charge a fare based on how many stops. Ability to let a passenger get off the bus Ability to keep track the number of passengers on the bus Ability to keep track each individual passenger on the bus Ability to keep track of the amount fares collected all time There is a maximum limit of capcity for the bus There is a maximum limit of stops on the route Class Passenger: Name of the passenger amount of money in his/her wallet (use integer to keep it simple) which stop to get on the bus which stop to get off the bus the java main function should have the following functions: create a bus object allow the user to create a number of passengers and specify the specifc details for each passenger, e. name, money amount, stop to get on and stop to get off Simulate and print out the activities alone the bus route as ustrated in the following diagram. and also in the screen shots
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
