SlideShare a Scribd company logo
1 of 14
Download to read offline
Project 3–Advanced Taxi SystemObjective
To gain experience and practice using classes.
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:
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:
Name
Charge per mile
Charge per trip
Checker Cab
0
30
GTS Lawrence
0.20
5
Jayhawk Taxi
0.80
1
$ 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...
Notes
You will likely need the vector, iomanip, and iostream libraries.
Deviating from the public / private requirements outlined above will incur penalties. Part of
what we are trying to learn in this project is lost if everything is public or global.
You should not need any more or any fewer class methods or attributes to accomplish this
project.
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
Given below are files for the question along with output. Please do rate the answer if it helped.
Thank you.
Time.h
#ifndef Time_h
#define Time_h
class Time
{
int h, m; //24 hour format
int getH(); //convert to 12 hr format
int getM(); //return minutes
public:
Time(int h, int m);
Time();
void setTime();
void print();
};
#endif /* Time_h */
Time.cpp
#include "Time.h"
#include
#include
using namespace std;
int Time::getH()
{
int hrs;
if(h == 0)
hrs = 12;
else if(h > 12)
hrs = h - 12;
else
hrs = h;
return hrs;
}
int Time::getM() //return minutes
{
return m;
}
Time::Time(int h, int m)
{
if(h >=0 && h <= 23)
this->h = h;
else
this->h = 0;
if(m >=0 && m <= 59)
this->m = m;
else
this->m = 0;
}
Time::Time()
{
this->h = 0;
this->m = 0;
}
void Time::setTime()
{
cout << "Enter the time with whitespace separating the hours and minutes: ";
cin >> h >> m;
}
void Time::print()
{
string ampm = "am";
if(h >= 12)
ampm = "pm";
cout << setw(2) << setfill('0') << getH() << ":" << setw(2) << getM() << " " << ampm;
cout << setfill(' ');
}
Taxi.h
#ifndef Taxi_h
#define Taxi_h
#include
#include
#include "Time.h"
using namespace std;
typedef struct
{
int miles;
Time pickup;
string passenger;
}Trip;
class Taxi
{
string name;
vector trips;
double rateMiles;
double rateTrips;
public:
Taxi(string n, double rM, double rT);
string getName();
double calculateTrip(Trip t);
double calculateCart();
void addTrip(Trip t);
void showTripx();
};
#endif /* Taxi_h */
Taxi.cpp
#include "Taxi.h"
Taxi::Taxi(string n, double rM, double rT)
{
name = n;
rateMiles = rM;
rateTrips = rT;
}
string Taxi::getName()
{
return name;
}
double Taxi::calculateTrip(Trip t)
{
double amount = rateTrips + t.miles * rateMiles;
return amount;
}
double Taxi::calculateCart()
{
double total = 0;
for(int i = 0; i < trips.size(); i++)
total += calculateTrip(trips[i]);
return total;
}
void Taxi::addTrip(Trip t)
{
trips.push_back(t);
}
void Taxi::showTripx()
{
double amount = calculateCart();
cout << "$" << amount << " pending with " << name << endl;
for(int i = 0; i < trips.size(); i++)
{
Trip t = trips[i];
cout << "tTrip scheduled for " << t.passenger << " covering " << t.miles << " miles at ";
t.pickup.print();
cout << endl;
}
cout << endl;
}
TaxiMain.cpp
#include "Taxi.h"
#include
#include
#include
using namespace std;
void orderTrip(vector &taxis);
void viewCart(vector &taxis);
int main()
{
vector taxis;
taxis.push_back(Taxi("Checker Cab", 0, 30));
taxis.push_back(Taxi("GTS Lawrence", 0.20, 5));
taxis.push_back(Taxi("Jayhawk Taxi", 0.80, 1));
int choice = 0;
cout << fixed << setprecision(2);
while(choice != 3)
{
cout << "=== Main Menu ===" << endl;
cout << "1. Order a trip" << endl;
cout << "2. View Cart" << endl;
cout << "3. Exit" << endl;
cout << "> ";
cin >> choice;
switch(choice)
{
case 1:
orderTrip(taxis);
break;
case 2:
viewCart(taxis);
break;
case 3:
break;
default:
cout << "Invalid chocie . Try again" << endl;
}
}
return 0;
}
void orderTrip(vector &taxis)
{
Trip trip;
int choice;
cout << "What is the passenger name? ";
cin >> trip.passenger;
cout << "How many miles would you like to travel ? ";
cin >> trip.miles;
trip.pickup.setTime();
cout << "Which company would you like to place the Trip with? " << endl;
for(int i = 0; i < 3; i++)
{
cout << (i+1) << taxis[i].getName() << " - " << taxis[i].calculateTrip(trip) << endl;
}
cout << "> ";
cin >> choice;
if(choice >= 1 && choice <= 3)
taxis[choice - 1].addTrip(trip);
else
cout << "Invalid choice!" << endl;
}
void viewCart(vector &taxis)
{
cout << "Active Trips:" << endl;
for(int i = 0; i < 3; i ++)
taxis[i].showTripx();
cout << endl;
}
output
=== Main Menu ===
1. Order a trip
2. View Cart
3. Exit
> 2
Active Trips:
$0.00 pending with Checker Cab
$0.00 pending with GTS Lawrence
$0.00 pending with Jayhawk Taxi
=== Main Menu ===
1. Order a trip
2. View Cart
3. Exit
> 1
What is the passenger 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?
1Checker Cab - 30.00
2GTS Lawrence - 7.00
3Jayhawk Taxi - 9.00
> 2
=== Main Menu ===
1. Order a trip
2. View Cart
3. Exit
> 2
Active Trips:
$0.00 pending with Checker Cab
$7.00 pending with GTS Lawrence
Trip scheduled for Bob covering 10 miles at 05:45 am
$0.00 pending with Jayhawk Taxi
=== Main Menu ===
1. Order a trip
2. View Cart
3. Exit
> 1
What is the passenger 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?
1Checker Cab - 30.00
2GTS Lawrence - 25.00
3Jayhawk Taxi - 81.00
> 2
=== Main Menu ===
1. Order a trip
2. View Cart
3. Exit
> 2
Active Trips:
$0.00 pending with Checker Cab
$32.00 pending with GTS Lawrence
Trip scheduled for Bob covering 10 miles at 05:45 am
Trip scheduled for Jane covering 100 miles at 06:20 pm
$0.00 pending with Jayhawk Taxi
=== Main Menu ===
1. Order a trip
2. View Cart
3. Exit
> 1
What is the passenger 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 like to place the Trip with?
1Checker Cab - 30.00
2GTS Lawrence - 5.80
3Jayhawk Taxi - 4.20
> 3
=== Main Menu ===
1. Order a trip
2. View Cart
3. Exit
> 2
Active Trips:
$0.00 pending with Checker Cab
$32.00 pending with GTS Lawrence
Trip scheduled for Bob covering 10 miles at 05:45 am
Trip scheduled for Jane covering 100 miles at 06:20 pm
$4.20 pending with Jayhawk Taxi
Trip scheduled for Sam covering 4 miles at 10:13 am
=== Main Menu ===
1. Order a trip
2. View Cart
3. Exit
> 1
What is the passenger 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?
1Checker Cab - 30.00
2GTS Lawrence - 45.00
3Jayhawk Taxi - 161.00
> 1
=== Main Menu ===
1. Order a trip
2. View Cart
3. Exit
> 2
Active Trips:
$30.00 pending with Checker Cab
Trip scheduled for Zoe covering 200 miles at 11:59 pm
$32.00 pending with GTS Lawrence
Trip scheduled for Bob covering 10 miles at 05:45 am
Trip scheduled for Jane covering 100 miles at 06:20 pm
$4.20 pending with Jayhawk Taxi
Trip scheduled for Sam covering 4 miles at 10:13 am
=== Main Menu ===
1. Order a trip
2. View Cart
3. Exit
> 3

More Related Content

Similar to Project 3–Advanced Taxi SystemObjectiveTo gain experience and prac.pdf

APassengerKnockOnDelayModelForTimetableOptimisation_beamer
APassengerKnockOnDelayModelForTimetableOptimisation_beamerAPassengerKnockOnDelayModelForTimetableOptimisation_beamer
APassengerKnockOnDelayModelForTimetableOptimisation_beamerPeter Sels
 
cbse 12 computer science IP
cbse 12 computer science IPcbse 12 computer science IP
cbse 12 computer science IPD. j Vicky
 
Practical Data Science : Data Cleaning and Summarising
Practical Data Science : Data Cleaning and SummarisingPractical Data Science : Data Cleaning and Summarising
Practical Data Science : Data Cleaning and SummarisingHariniMS1
 
12th CBSE Practical File
12th CBSE Practical File12th CBSE Practical File
12th CBSE Practical FileAshwin Francis
 
CAR PARKING SYSTEM USING VISUAL STUDIO C++ (OPERATING SYSTEM MINI PROJECT )
CAR PARKING SYSTEM USING VISUAL STUDIO C++ (OPERATING SYSTEM MINI PROJECT ) CAR PARKING SYSTEM USING VISUAL STUDIO C++ (OPERATING SYSTEM MINI PROJECT )
CAR PARKING SYSTEM USING VISUAL STUDIO C++ (OPERATING SYSTEM MINI PROJECT ) Mauryasuraj98
 
Standing the Test of Time: The Date Provider Pattern
Standing the Test of Time: The Date Provider PatternStanding the Test of Time: The Date Provider Pattern
Standing the Test of Time: The Date Provider PatternDerek Lee Boire
 
Programming with People
Programming with PeopleProgramming with People
Programming with PeopleEmery Berger
 
Mixed Integer Linear Programming Formulation for the Taxi Sharing Problem
Mixed Integer Linear Programming Formulation for the Taxi Sharing ProblemMixed Integer Linear Programming Formulation for the Taxi Sharing Problem
Mixed Integer Linear Programming Formulation for the Taxi Sharing Problemjfrchicanog
 
When and where are bus express services justified?
When and where are bus express services justified?When and where are bus express services justified?
When and where are bus express services justified?BRTCoE
 
soal program borland c++ (stasiun kereta api)
soal program borland c++ (stasiun kereta api)soal program borland c++ (stasiun kereta api)
soal program borland c++ (stasiun kereta api)ichal48
 
I need help to modify my code according to the instructions- Modify th.pdf
I need help to modify my code according to the instructions- Modify th.pdfI need help to modify my code according to the instructions- Modify th.pdf
I need help to modify my code according to the instructions- Modify th.pdfpnaran46
 
[OOP - Lec 16,17] Objects as Function Parameter and ReturnType
[OOP - Lec 16,17] Objects as Function Parameter and ReturnType[OOP - Lec 16,17] Objects as Function Parameter and ReturnType
[OOP - Lec 16,17] Objects as Function Parameter and ReturnTypeMuhammad Hammad Waseem
 
COMPUTER SCIENCE PROJECT OF RAILWAY RESERVATION SYSTEM PYTHON PROGRAMMING.pdf
COMPUTER SCIENCE PROJECT OF RAILWAY RESERVATION SYSTEM PYTHON PROGRAMMING.pdfCOMPUTER SCIENCE PROJECT OF RAILWAY RESERVATION SYSTEM PYTHON PROGRAMMING.pdf
COMPUTER SCIENCE PROJECT OF RAILWAY RESERVATION SYSTEM PYTHON PROGRAMMING.pdfAkshatTiwari530170
 
Create a system to simulate vehicles at an intersection. Assume th.pdf
Create a system to simulate vehicles at an intersection. Assume th.pdfCreate a system to simulate vehicles at an intersection. Assume th.pdf
Create a system to simulate vehicles at an intersection. Assume th.pdfarchanacomputers1
 
Amazon_Collider_Project
Amazon_Collider_ProjectAmazon_Collider_Project
Amazon_Collider_ProjectAbbey Chaver
 
Assignment#1
Assignment#1Assignment#1
Assignment#1NA000000
 

Similar to Project 3–Advanced Taxi SystemObjectiveTo gain experience and prac.pdf (20)

APassengerKnockOnDelayModelForTimetableOptimisation_beamer
APassengerKnockOnDelayModelForTimetableOptimisation_beamerAPassengerKnockOnDelayModelForTimetableOptimisation_beamer
APassengerKnockOnDelayModelForTimetableOptimisation_beamer
 
cbse 12 computer science IP
cbse 12 computer science IPcbse 12 computer science IP
cbse 12 computer science IP
 
Assign transportation
Assign transportationAssign transportation
Assign transportation
 
Practical Data Science : Data Cleaning and Summarising
Practical Data Science : Data Cleaning and SummarisingPractical Data Science : Data Cleaning and Summarising
Practical Data Science : Data Cleaning and Summarising
 
CabModelWriteup
CabModelWriteupCabModelWriteup
CabModelWriteup
 
12th CBSE Practical File
12th CBSE Practical File12th CBSE Practical File
12th CBSE Practical File
 
CAR PARKING SYSTEM USING VISUAL STUDIO C++ (OPERATING SYSTEM MINI PROJECT )
CAR PARKING SYSTEM USING VISUAL STUDIO C++ (OPERATING SYSTEM MINI PROJECT ) CAR PARKING SYSTEM USING VISUAL STUDIO C++ (OPERATING SYSTEM MINI PROJECT )
CAR PARKING SYSTEM USING VISUAL STUDIO C++ (OPERATING SYSTEM MINI PROJECT )
 
Standing the Test of Time: The Date Provider Pattern
Standing the Test of Time: The Date Provider PatternStanding the Test of Time: The Date Provider Pattern
Standing the Test of Time: The Date Provider Pattern
 
Programming with People
Programming with PeopleProgramming with People
Programming with People
 
Statement
StatementStatement
Statement
 
Mixed Integer Linear Programming Formulation for the Taxi Sharing Problem
Mixed Integer Linear Programming Formulation for the Taxi Sharing ProblemMixed Integer Linear Programming Formulation for the Taxi Sharing Problem
Mixed Integer Linear Programming Formulation for the Taxi Sharing Problem
 
When and where are bus express services justified?
When and where are bus express services justified?When and where are bus express services justified?
When and where are bus express services justified?
 
soal program borland c++ (stasiun kereta api)
soal program borland c++ (stasiun kereta api)soal program borland c++ (stasiun kereta api)
soal program borland c++ (stasiun kereta api)
 
I need help to modify my code according to the instructions- Modify th.pdf
I need help to modify my code according to the instructions- Modify th.pdfI need help to modify my code according to the instructions- Modify th.pdf
I need help to modify my code according to the instructions- Modify th.pdf
 
[OOP - Lec 16,17] Objects as Function Parameter and ReturnType
[OOP - Lec 16,17] Objects as Function Parameter and ReturnType[OOP - Lec 16,17] Objects as Function Parameter and ReturnType
[OOP - Lec 16,17] Objects as Function Parameter and ReturnType
 
COMPUTER SCIENCE PROJECT OF RAILWAY RESERVATION SYSTEM PYTHON PROGRAMMING.pdf
COMPUTER SCIENCE PROJECT OF RAILWAY RESERVATION SYSTEM PYTHON PROGRAMMING.pdfCOMPUTER SCIENCE PROJECT OF RAILWAY RESERVATION SYSTEM PYTHON PROGRAMMING.pdf
COMPUTER SCIENCE PROJECT OF RAILWAY RESERVATION SYSTEM PYTHON PROGRAMMING.pdf
 
Create a system to simulate vehicles at an intersection. Assume th.pdf
Create a system to simulate vehicles at an intersection. Assume th.pdfCreate a system to simulate vehicles at an intersection. Assume th.pdf
Create a system to simulate vehicles at an intersection. Assume th.pdf
 
Amazon_Collider_Project
Amazon_Collider_ProjectAmazon_Collider_Project
Amazon_Collider_Project
 
Assignment#1
Assignment#1Assignment#1
Assignment#1
 
Operation Research
Operation ResearchOperation Research
Operation Research
 

More from aminbijal86

can someone proofread this for meAs a child, I used to watch T.V..pdf
can someone proofread this for meAs a child, I used to watch T.V..pdfcan someone proofread this for meAs a child, I used to watch T.V..pdf
can someone proofread this for meAs a child, I used to watch T.V..pdfaminbijal86
 
Describe the arrangement of Regulations for lifting machines and acc.pdf
Describe the arrangement of Regulations for lifting machines and acc.pdfDescribe the arrangement of Regulations for lifting machines and acc.pdf
Describe the arrangement of Regulations for lifting machines and acc.pdfaminbijal86
 
All of the following would require use of the equity method for inve.pdf
All of the following would require use of the equity method for inve.pdfAll of the following would require use of the equity method for inve.pdf
All of the following would require use of the equity method for inve.pdfaminbijal86
 
A nurse palpated enlarged lymph nodes. Describe signs and symptoms t.pdf
A nurse palpated enlarged lymph nodes. Describe signs and symptoms t.pdfA nurse palpated enlarged lymph nodes. Describe signs and symptoms t.pdf
A nurse palpated enlarged lymph nodes. Describe signs and symptoms t.pdfaminbijal86
 
Bell & Porter has the following average times (in hours) Inspecting .pdf
Bell & Porter has the following average times (in hours) Inspecting .pdfBell & Porter has the following average times (in hours) Inspecting .pdf
Bell & Porter has the following average times (in hours) Inspecting .pdfaminbijal86
 
Which part of the clavicle is most commonly fractured A. Later.pdf
Which part of the clavicle is most commonly fractured A. Later.pdfWhich part of the clavicle is most commonly fractured A. Later.pdf
Which part of the clavicle is most commonly fractured A. Later.pdfaminbijal86
 
Which of the following is NOT a criticism of the National Bureau of .pdf
Which of the following is NOT a criticism of the National Bureau of .pdfWhich of the following is NOT a criticism of the National Bureau of .pdf
Which of the following is NOT a criticism of the National Bureau of .pdfaminbijal86
 
When working with communications, is it more important to detect or .pdf
When working with communications, is it more important to detect or .pdfWhen working with communications, is it more important to detect or .pdf
When working with communications, is it more important to detect or .pdfaminbijal86
 
Which of the following are principles of the AICPA Code of Professio.pdf
Which of the following are principles of the AICPA Code of Professio.pdfWhich of the following are principles of the AICPA Code of Professio.pdf
Which of the following are principles of the AICPA Code of Professio.pdfaminbijal86
 
Thouhgts on the future of information technology (IT) software secur.pdf
Thouhgts on the future of information technology (IT) software secur.pdfThouhgts on the future of information technology (IT) software secur.pdf
Thouhgts on the future of information technology (IT) software secur.pdfaminbijal86
 
Two of the following ions depend on their conversion into a gas .pdf
Two of the following ions depend on their conversion into a gas .pdfTwo of the following ions depend on their conversion into a gas .pdf
Two of the following ions depend on their conversion into a gas .pdfaminbijal86
 
The systemic acquired resistance (SAR) demonstrated in the experimen.pdf
The systemic acquired resistance (SAR) demonstrated in the experimen.pdfThe systemic acquired resistance (SAR) demonstrated in the experimen.pdf
The systemic acquired resistance (SAR) demonstrated in the experimen.pdfaminbijal86
 
One implication of the Lyon hypothesis was that adult females would b.pdf
One implication of the Lyon hypothesis was that adult females would b.pdfOne implication of the Lyon hypothesis was that adult females would b.pdf
One implication of the Lyon hypothesis was that adult females would b.pdfaminbijal86
 
the problems of vietnam in communication during international busine.pdf
the problems of vietnam in communication during international busine.pdfthe problems of vietnam in communication during international busine.pdf
the problems of vietnam in communication during international busine.pdfaminbijal86
 
The first signs of niacin deficiency are all of the following EXCEPT .pdf
The first signs of niacin deficiency are all of the following EXCEPT .pdfThe first signs of niacin deficiency are all of the following EXCEPT .pdf
The first signs of niacin deficiency are all of the following EXCEPT .pdfaminbijal86
 
The Ba(s) gets formed after reductionBa2+ + 2e- -- Ba(s) which is.pdf
The Ba(s) gets formed after reductionBa2+ + 2e- -- Ba(s) which is.pdfThe Ba(s) gets formed after reductionBa2+ + 2e- -- Ba(s) which is.pdf
The Ba(s) gets formed after reductionBa2+ + 2e- -- Ba(s) which is.pdfaminbijal86
 
Submit a 2-3 page paper addressing each of the following 1.Define .pdf
Submit a 2-3 page paper addressing each of the following 1.Define .pdfSubmit a 2-3 page paper addressing each of the following 1.Define .pdf
Submit a 2-3 page paper addressing each of the following 1.Define .pdfaminbijal86
 
Nessus is a network security toolIn a pragraph describe the tool’s.pdf
Nessus is a network security toolIn a pragraph describe the tool’s.pdfNessus is a network security toolIn a pragraph describe the tool’s.pdf
Nessus is a network security toolIn a pragraph describe the tool’s.pdfaminbijal86
 
Solve given LP problem using simplex method and find maximum value o.pdf
Solve given LP problem using simplex method and find maximum value o.pdfSolve given LP problem using simplex method and find maximum value o.pdf
Solve given LP problem using simplex method and find maximum value o.pdfaminbijal86
 
Show a rightmost derivation for the string(id + id) id Usin.pdf
Show a rightmost derivation for the string(id + id)  id Usin.pdfShow a rightmost derivation for the string(id + id)  id Usin.pdf
Show a rightmost derivation for the string(id + id) id Usin.pdfaminbijal86
 

More from aminbijal86 (20)

can someone proofread this for meAs a child, I used to watch T.V..pdf
can someone proofread this for meAs a child, I used to watch T.V..pdfcan someone proofread this for meAs a child, I used to watch T.V..pdf
can someone proofread this for meAs a child, I used to watch T.V..pdf
 
Describe the arrangement of Regulations for lifting machines and acc.pdf
Describe the arrangement of Regulations for lifting machines and acc.pdfDescribe the arrangement of Regulations for lifting machines and acc.pdf
Describe the arrangement of Regulations for lifting machines and acc.pdf
 
All of the following would require use of the equity method for inve.pdf
All of the following would require use of the equity method for inve.pdfAll of the following would require use of the equity method for inve.pdf
All of the following would require use of the equity method for inve.pdf
 
A nurse palpated enlarged lymph nodes. Describe signs and symptoms t.pdf
A nurse palpated enlarged lymph nodes. Describe signs and symptoms t.pdfA nurse palpated enlarged lymph nodes. Describe signs and symptoms t.pdf
A nurse palpated enlarged lymph nodes. Describe signs and symptoms t.pdf
 
Bell & Porter has the following average times (in hours) Inspecting .pdf
Bell & Porter has the following average times (in hours) Inspecting .pdfBell & Porter has the following average times (in hours) Inspecting .pdf
Bell & Porter has the following average times (in hours) Inspecting .pdf
 
Which part of the clavicle is most commonly fractured A. Later.pdf
Which part of the clavicle is most commonly fractured A. Later.pdfWhich part of the clavicle is most commonly fractured A. Later.pdf
Which part of the clavicle is most commonly fractured A. Later.pdf
 
Which of the following is NOT a criticism of the National Bureau of .pdf
Which of the following is NOT a criticism of the National Bureau of .pdfWhich of the following is NOT a criticism of the National Bureau of .pdf
Which of the following is NOT a criticism of the National Bureau of .pdf
 
When working with communications, is it more important to detect or .pdf
When working with communications, is it more important to detect or .pdfWhen working with communications, is it more important to detect or .pdf
When working with communications, is it more important to detect or .pdf
 
Which of the following are principles of the AICPA Code of Professio.pdf
Which of the following are principles of the AICPA Code of Professio.pdfWhich of the following are principles of the AICPA Code of Professio.pdf
Which of the following are principles of the AICPA Code of Professio.pdf
 
Thouhgts on the future of information technology (IT) software secur.pdf
Thouhgts on the future of information technology (IT) software secur.pdfThouhgts on the future of information technology (IT) software secur.pdf
Thouhgts on the future of information technology (IT) software secur.pdf
 
Two of the following ions depend on their conversion into a gas .pdf
Two of the following ions depend on their conversion into a gas .pdfTwo of the following ions depend on their conversion into a gas .pdf
Two of the following ions depend on their conversion into a gas .pdf
 
The systemic acquired resistance (SAR) demonstrated in the experimen.pdf
The systemic acquired resistance (SAR) demonstrated in the experimen.pdfThe systemic acquired resistance (SAR) demonstrated in the experimen.pdf
The systemic acquired resistance (SAR) demonstrated in the experimen.pdf
 
One implication of the Lyon hypothesis was that adult females would b.pdf
One implication of the Lyon hypothesis was that adult females would b.pdfOne implication of the Lyon hypothesis was that adult females would b.pdf
One implication of the Lyon hypothesis was that adult females would b.pdf
 
the problems of vietnam in communication during international busine.pdf
the problems of vietnam in communication during international busine.pdfthe problems of vietnam in communication during international busine.pdf
the problems of vietnam in communication during international busine.pdf
 
The first signs of niacin deficiency are all of the following EXCEPT .pdf
The first signs of niacin deficiency are all of the following EXCEPT .pdfThe first signs of niacin deficiency are all of the following EXCEPT .pdf
The first signs of niacin deficiency are all of the following EXCEPT .pdf
 
The Ba(s) gets formed after reductionBa2+ + 2e- -- Ba(s) which is.pdf
The Ba(s) gets formed after reductionBa2+ + 2e- -- Ba(s) which is.pdfThe Ba(s) gets formed after reductionBa2+ + 2e- -- Ba(s) which is.pdf
The Ba(s) gets formed after reductionBa2+ + 2e- -- Ba(s) which is.pdf
 
Submit a 2-3 page paper addressing each of the following 1.Define .pdf
Submit a 2-3 page paper addressing each of the following 1.Define .pdfSubmit a 2-3 page paper addressing each of the following 1.Define .pdf
Submit a 2-3 page paper addressing each of the following 1.Define .pdf
 
Nessus is a network security toolIn a pragraph describe the tool’s.pdf
Nessus is a network security toolIn a pragraph describe the tool’s.pdfNessus is a network security toolIn a pragraph describe the tool’s.pdf
Nessus is a network security toolIn a pragraph describe the tool’s.pdf
 
Solve given LP problem using simplex method and find maximum value o.pdf
Solve given LP problem using simplex method and find maximum value o.pdfSolve given LP problem using simplex method and find maximum value o.pdf
Solve given LP problem using simplex method and find maximum value o.pdf
 
Show a rightmost derivation for the string(id + id) id Usin.pdf
Show a rightmost derivation for the string(id + id)  id Usin.pdfShow a rightmost derivation for the string(id + id)  id Usin.pdf
Show a rightmost derivation for the string(id + id) id Usin.pdf
 

Recently uploaded

Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 

Recently uploaded (20)

Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 

Project 3–Advanced Taxi SystemObjectiveTo gain experience and prac.pdf

  • 1. Project 3–Advanced Taxi SystemObjective To gain experience and practice using classes. 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
  • 2. -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: 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
  • 3. 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: Name Charge per mile Charge per trip Checker Cab 0 30 GTS Lawrence 0.20 5 Jayhawk Taxi 0.80 1 $ 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:
  • 4. 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... Notes You will likely need the vector, iomanip, and iostream libraries. Deviating from the public / private requirements outlined above will incur penalties. Part of
  • 5. what we are trying to learn in this project is lost if everything is public or global. You should not need any more or any fewer class methods or attributes to accomplish this project. 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 Given below are files for the question along with output. Please do rate the answer if it helped. Thank you. Time.h #ifndef Time_h #define Time_h class Time { int h, m; //24 hour format int getH(); //convert to 12 hr format int getM(); //return minutes public: Time(int h, int m);
  • 6. Time(); void setTime(); void print(); }; #endif /* Time_h */ Time.cpp #include "Time.h" #include #include using namespace std; int Time::getH() { int hrs; if(h == 0) hrs = 12; else if(h > 12) hrs = h - 12; else hrs = h; return hrs; } int Time::getM() //return minutes { return m; } Time::Time(int h, int m) { if(h >=0 && h <= 23) this->h = h; else this->h = 0; if(m >=0 && m <= 59) this->m = m; else
  • 7. this->m = 0; } Time::Time() { this->h = 0; this->m = 0; } void Time::setTime() { cout << "Enter the time with whitespace separating the hours and minutes: "; cin >> h >> m; } void Time::print() { string ampm = "am"; if(h >= 12) ampm = "pm"; cout << setw(2) << setfill('0') << getH() << ":" << setw(2) << getM() << " " << ampm; cout << setfill(' '); } Taxi.h #ifndef Taxi_h #define Taxi_h #include #include #include "Time.h" using namespace std; typedef struct { int miles; Time pickup; string passenger; }Trip; class Taxi {
  • 8. string name; vector trips; double rateMiles; double rateTrips; public: Taxi(string n, double rM, double rT); string getName(); double calculateTrip(Trip t); double calculateCart(); void addTrip(Trip t); void showTripx(); }; #endif /* Taxi_h */ Taxi.cpp #include "Taxi.h" Taxi::Taxi(string n, double rM, double rT) { name = n; rateMiles = rM; rateTrips = rT; } string Taxi::getName() { return name; } double Taxi::calculateTrip(Trip t) { double amount = rateTrips + t.miles * rateMiles; return amount; } double Taxi::calculateCart() { double total = 0; for(int i = 0; i < trips.size(); i++) total += calculateTrip(trips[i]);
  • 9. return total; } void Taxi::addTrip(Trip t) { trips.push_back(t); } void Taxi::showTripx() { double amount = calculateCart(); cout << "$" << amount << " pending with " << name << endl; for(int i = 0; i < trips.size(); i++) { Trip t = trips[i]; cout << "tTrip scheduled for " << t.passenger << " covering " << t.miles << " miles at "; t.pickup.print(); cout << endl; } cout << endl; } TaxiMain.cpp #include "Taxi.h" #include #include #include using namespace std; void orderTrip(vector &taxis); void viewCart(vector &taxis); int main() { vector taxis; taxis.push_back(Taxi("Checker Cab", 0, 30)); taxis.push_back(Taxi("GTS Lawrence", 0.20, 5)); taxis.push_back(Taxi("Jayhawk Taxi", 0.80, 1)); int choice = 0; cout << fixed << setprecision(2);
  • 10. while(choice != 3) { cout << "=== Main Menu ===" << endl; cout << "1. Order a trip" << endl; cout << "2. View Cart" << endl; cout << "3. Exit" << endl; cout << "> "; cin >> choice; switch(choice) { case 1: orderTrip(taxis); break; case 2: viewCart(taxis); break; case 3: break; default: cout << "Invalid chocie . Try again" << endl; } } return 0; } void orderTrip(vector &taxis) { Trip trip; int choice; cout << "What is the passenger name? "; cin >> trip.passenger; cout << "How many miles would you like to travel ? "; cin >> trip.miles;
  • 11. trip.pickup.setTime(); cout << "Which company would you like to place the Trip with? " << endl; for(int i = 0; i < 3; i++) { cout << (i+1) << taxis[i].getName() << " - " << taxis[i].calculateTrip(trip) << endl; } cout << "> "; cin >> choice; if(choice >= 1 && choice <= 3) taxis[choice - 1].addTrip(trip); else cout << "Invalid choice!" << endl; } void viewCart(vector &taxis) { cout << "Active Trips:" << endl; for(int i = 0; i < 3; i ++) taxis[i].showTripx(); cout << endl; } output === Main Menu === 1. Order a trip 2. View Cart 3. Exit > 2 Active Trips: $0.00 pending with Checker Cab $0.00 pending with GTS Lawrence $0.00 pending with Jayhawk Taxi === Main Menu === 1. Order a trip
  • 12. 2. View Cart 3. Exit > 1 What is the passenger 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? 1Checker Cab - 30.00 2GTS Lawrence - 7.00 3Jayhawk Taxi - 9.00 > 2 === Main Menu === 1. Order a trip 2. View Cart 3. Exit > 2 Active Trips: $0.00 pending with Checker Cab $7.00 pending with GTS Lawrence Trip scheduled for Bob covering 10 miles at 05:45 am $0.00 pending with Jayhawk Taxi === Main Menu === 1. Order a trip 2. View Cart 3. Exit > 1 What is the passenger 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? 1Checker Cab - 30.00 2GTS Lawrence - 25.00 3Jayhawk Taxi - 81.00 > 2 === Main Menu ===
  • 13. 1. Order a trip 2. View Cart 3. Exit > 2 Active Trips: $0.00 pending with Checker Cab $32.00 pending with GTS Lawrence Trip scheduled for Bob covering 10 miles at 05:45 am Trip scheduled for Jane covering 100 miles at 06:20 pm $0.00 pending with Jayhawk Taxi === Main Menu === 1. Order a trip 2. View Cart 3. Exit > 1 What is the passenger 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 like to place the Trip with? 1Checker Cab - 30.00 2GTS Lawrence - 5.80 3Jayhawk Taxi - 4.20 > 3 === Main Menu === 1. Order a trip 2. View Cart 3. Exit > 2 Active Trips: $0.00 pending with Checker Cab $32.00 pending with GTS Lawrence Trip scheduled for Bob covering 10 miles at 05:45 am Trip scheduled for Jane covering 100 miles at 06:20 pm $4.20 pending with Jayhawk Taxi Trip scheduled for Sam covering 4 miles at 10:13 am
  • 14. === Main Menu === 1. Order a trip 2. View Cart 3. Exit > 1 What is the passenger 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? 1Checker Cab - 30.00 2GTS Lawrence - 45.00 3Jayhawk Taxi - 161.00 > 1 === Main Menu === 1. Order a trip 2. View Cart 3. Exit > 2 Active Trips: $30.00 pending with Checker Cab Trip scheduled for Zoe covering 200 miles at 11:59 pm $32.00 pending with GTS Lawrence Trip scheduled for Bob covering 10 miles at 05:45 am Trip scheduled for Jane covering 100 miles at 06:20 pm $4.20 pending with Jayhawk Taxi Trip scheduled for Sam covering 4 miles at 10:13 am === Main Menu === 1. Order a trip 2. View Cart 3. Exit > 3