C HELP Problem As a concierge at a local hotel you would lik

C++ HELP:

Problem

As a concierge at a local hotel, you would like to simplify your work when ordering taxi rides for your customers. Write a program that will place orders with local taxi companies for your customers.

Specifications

For your program, implement two classes and a struct. You will have a class for taxi companies, a class for times, and a struct for orders. The class and struct attributes and methods should be as follows:

Time

-int h, m

stores the time in 24h mode

-void rollForward()

-int getH()

converts h to 12-hour mode, used by print

-int getM()

returns m, used by print

+Time(int h, int m)

constructor, sets h and m

+Time()

constructor, doesn’t set anything

+void setTime()

asks the user to input time in 24h mode

+void print()

nicely prints the time in 12h mode

Trip

int miles

Time pickup

string passenger

Taxi

-string name

stores the name of the taxi company

-vector< Trip > trips

stores the list of trips ordered with the company

-double rateMiles

stores the charge per mile

-double rateTrips

stores the charge per trip (flat rate)

+Taxi(string n, double rM, double rT)

constructor that sets the name, and rates

+string getName()

returns the company’s name

+double calculateTrip(Trip t)

calculates the cost of the trip passed as argument

+double calculateCart()

calculates cost of all pending orders

+void addTrip(Trip t)

adds a trip to the list of orders

+void showTripx()

prints the total pending cost and shows all trips

In int main, you should start by establishing an array of three taxi companies. The following properties should be given to each taxi company:

Name

Charge per mile

Charge per trip

Checker Cab

0

30

GTS Lawrence

0.20

5

Jayhawk Taxi

0.80

1

Build a menu system that will allow the user to order a trip, view their cart, or exit.

Ordering a trip should ask the user for the passenger’s name, the number of miles to be driven, and use the Time class method to get the time of the pickup. Create a Trip instance with those pieces of information. Next, display a submenu for the user to choose a taxi company from which to order. Show the cost the trip would be with each company using the calculateTrip class method. Use a for loop to iterate over your taxi company array rather than re-writing the same basic menu option for each company. When the user selects a company to place the order with, us the addTrip class method of the corresponding taxi company to add the Trip instance you created earlier.

Viewing the cart should use a for loop to iterate over the companies in the array, calling the showTrips class method for each.

Sample Output: Normal Operation (user input in italics)

>2
Active Trips:

>1
What is the passenger\'s first name? Bob
How many miles would you like to travel? 10
Enter the time with whitespace separating the hours and minutes: 5 45 Which company would you like to place the Trip with?
1. Checker Cab - $30.00
2. GTS Lawrence - $7.00
3. Jayhawk Taxi - $9.00
>2

>2
Active Trips:

$ 7.00 pending with GTS Lawrence
Trip scheduled for Bob covering 10 miles with pickup at 05:45 am

>1
What is the passenger\'s first name? Jane
How many miles would you like to travel? 100
Enter the time with whitespace separating the hours and minutes: 18 20 Which company would you like to place the Trip with?
1. Checker Cab - $30.00
2. GTS Lawrence - $25.00
3. Jayhawk Taxi - $81.00
>2
===Main Menu===
1. Order a trip
2. View Cart
3. Exit
>2
Active Trips:

Trip scheduled for Bob covering 10 miles with pickup at 05:45 am

Trip scheduled for Jane covering 100 miles with pickup at 06:20 pm $ 0.00 pending with Jayhawk Taxi

>1
What is the passenger\'s first name? Sam
How many miles would you like to travel? 4
Enter the time with whitespace separating the hours and minutes: 10 13

Which company would you 1. Checker Cab - $30.00 2. GTS Lawrence - $5.80 3. Jayhawk Taxi - $4.20 >3

>2
Active Trips:
$ 0.00 pending with Checker Cab $ 32.00 pending with GTS Lawrence

Trip scheduled for Bob covering 10 miles with pickup at 05:45 am

Trip scheduled for Jane covering 100 miles with pickup at 06:20 pm $ 4.20 pending with Jayhawk Taxi

Trip scheduled for Sam covering 4 miles with pickup at 10:13 am

>1
What is the passenger\'s first name? Zoe
How many miles would you like to travel? 200
Enter the time with whitespace separating the hours and minutes: 23 59 Which company would you like to place the Trip with?
1. Checker Cab - $30.00

2. GTS Lawrence - $45.00 3. Jayhawk Taxi - $161.00 >1

>2
Active Trips:
$ 30.00 pending with Checker Cab

Trip scheduled for Zoe covering 200 miles with pickup at 11:59 pm $ 32.00 pending with GTS Lawrence

Trip scheduled for Bob covering 10 miles with pickup at 05:45 am

Trip scheduled for Jane covering 100 miles with pickup at 06:20 pm $ 4.20 pending with Jayhawk Taxi

Trip scheduled for Sam covering 4 miles with pickup at 10:13 am

>3 Exiting...

Time

-int h, m

stores the time in 24h mode

-void rollForward()

-int getH()

converts h to 12-hour mode, used by print

-int getM()

returns m, used by print

+Time(int h, int m)

constructor, sets h and m

+Time()

constructor, doesn’t set anything

+void setTime()

asks the user to input time in 24h mode

+void print()

nicely prints the time in 12h mode

Solution

#include<iostream>
#include<vector>
using namespace std;

class Time
{
int h,m;

public:
void rollForward(){}
int getH(){return h;}
int getM(){return m;}

Time(int h,int m){this->h=h;this->m=m;}
Time(){}

void setTime(){
   cout<<\"Enter Hours,mins in 24hr format:\";
   cin>>h>>m;
}

void print(){

    int hr=(h>12)? 24-h:h;

   cout<<\"Time is \"<<hr<<\":\"<<m<<\" \"<<((h>12)?\"PM\":\"AM\")<<endl;
}

};

typedef struct trip
{
int Miles;
Time pickup;
string passanger;

}Trip;

class Taxi
{
string name;
double rM,rT;
vector<Trip> trips;

public:
    Taxi(string n,double rm, double rt){
      rM=rm;rT=rt;
      name=n;
   }

   string getName(){ return name;}

   double calculateCart(){
       if(trips.size()==0)
           cout<<\"$ 0.00 trips pending with \"<<getName()<<endl;
       else{
          for(int i=0;i<trips.size();i++)
           cout<<\"$ \"<<(trips[i].Miles*rM+rT)<<\" trip for \"<<trips[i].passanger<<\" is pending with \"<<getName()<<endl;
       }
   }

   double calculateTrip(Trip t){
       cout<<\"$ \"<<(t.Miles*rM+rT)<<\" with \"<<getName()<<endl;
   }

   void addTrip(Trip T){ trips.push_back(T);}

   void showTripx(){}
  
  


};

int main(void)
{

Taxi t[3]={Taxi(\"Checker Cab\",0,30), Taxi(\"GTS Lawrence\",0.20,5), Taxi(\"Jayhawk Taxi\",0.8,1)};

int opt,hr,min;
Trip tr;

while(1)
{
    cout<<\"====Main Menu====\"<<endl;
    cout<<\"1. Order a trip\"<<endl<<\"2. View Cart\"<<endl<<\"3. Exit\"<<endl;
    cin>>opt;
  
    switch(opt){
   case 1:
       cout<<\"Passanger name:\";
       cin>>tr.passanger;
       cout<<\"number of miles to travel:\";
       cin>>tr.Miles;
       cout<<\"time of travel hours mins :\";
       tr.pickup.setTime();

       cout<<\"Select the taxi company you like to travel\"<<endl;
       for(int i=0;i<3;i++)
          cout<<i+1<<\".\"<<t[i].calculateTrip(tr)<<endl;

       cin>>opt;
       t[opt].addTrip(tr);

       break;
   case 2:
       for(int i=0;i<3;i++)
       t[i].calculateCart();

       break;
   default:
       cout<<\"Exiting...\"<<endl;
       return 0;
    }
}

return 0;
}

C++ HELP: Problem As a concierge at a local hotel, you would like to simplify your work when ordering taxi rides for your customers. Write a program that will p
C++ HELP: Problem As a concierge at a local hotel, you would like to simplify your work when ordering taxi rides for your customers. Write a program that will p
C++ HELP: Problem As a concierge at a local hotel, you would like to simplify your work when ordering taxi rides for your customers. Write a program that will p
C++ HELP: Problem As a concierge at a local hotel, you would like to simplify your work when ordering taxi rides for your customers. Write a program that will p
C++ HELP: Problem As a concierge at a local hotel, you would like to simplify your work when ordering taxi rides for your customers. Write a program that will p
C++ HELP: Problem As a concierge at a local hotel, you would like to simplify your work when ordering taxi rides for your customers. Write a program that will p

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site