Answered step by step
Verified Expert Solution
Question
1 Approved Answer
PROBLEM 7 . Create a function to request a taxi having the following interface: requestTaxi - > PassengerTelephoneNumber, PassengerLocation, PassengerDestination - > void If the
PROBLEM Create a function to request a taxi having the following interface:
requestTaxi PassengerTelephoneNumber, PassengerLocation, PassengerDestination void
If the start and end locations are the same then an appropriate error message is to be displayed and no further action is to be taken. The appropriate error message is "Start and end locations are the same!"
Provided that the locations are correct, the fare should be displayed and the passenger asked to enter Y to confirm the trip or N to cancel. The specific message to the passenger is 'Enter Y to confirm the trip or N to cancel
After the user confirms the trip, you should determine if there is a driver available. If so execute the trip. The driver should now be reflected in the destination location and their trip count should have increased. Reset any failed trip attempts the passenger had to zero. If not, record the failed attempt for this passenger by adding and display an appropriate error message. The appropriate error message is No driver available'.
Hackerrank Submission Instructions
For Problem in the function the parameters PassengerLocation and PassengerDestination will contain only one of the following, "UWI", "Papine", "Liguanea", "HalfWayTree". Where the start and end locations are the same, the appropriate error message is "Start and end locations are the same!" Only the calculated fare should be displayed ie without any message or description After the fare is displayed, the message to the passenger is 'Enter Y to confirm the trip or N to cancel For a failed attempt, the appropriate error message is No driver available'.
Input Format
The number of drivers, d
d lines of driver information First Name, Last Name, Car Make and Model, LocationUWIPapineLiguaneaHalfWayTree
The number of passengers, p
p lines of taxi request information Passenger Telephone, Location, Destination
The number of known passengers, k
k lines of known passenger information Passenger Telephone, Failed Attempts
The standard fare for all trips
Y or N Y to request a taxi or N to end use of the service for that period
Y or N or No further informationY to confirm the trip or N to cancel This input will be present only if Y was entered for the previous input to confirm the trip AND start location differ from end location
The above lines are repeated based on the number of taxi requests.
Constraints
None
Output Format
Start and end locations are the same! or No information This is shown appended to the previous line
The calculated fare for a trip Shown as Float This is shown appended to the previous line, except for first taxi request and No driver available for previous request OR Start and end locations are the same!
Enter Y to confirm the trip or N to cancel
No driver available or No further information This is shown appended to the previous line
The above lines are repeated based on the number of taxi requests.
Sample Input
St Johnnie,Dacosta, Toyota Ipsum,UWI
Patricia,Palmer, Volkswagen Passat,Liguanea
Maxine,Jones, Volvo V Est,HalfWayTree
Papine UWI
UWI Liguanea
HalfWayTree Papine
Y
Y
Y
Y
Y
Y
N
Sample Output
Enter Y to confirm the trip or N to cancel No driver available
Enter Y to confirm the trip or N to cancel
Enter Y to confirm the trip or N to cancel
Papine Maxine Jones
Liguanea Patricia Palmer
Liguanea St Johnnie Dacosta
Sample Input
St Johnnie,Dacosta, Toyota Ipsum,UWI
Patricia,Palmer, Volkswagen Passat,Liguanea
Maxine,Jones, Volvo V Est,HalfWayTree
Andrew,Zephers, Suzuki Swift,HalfWayTree
Carlton,Rangers, Subaru Legacy,Liguanea
Everton,Shroeter, Nissan Tiida,HalfWayTree
George,Andrews, Mitsubishi Spacewagon,HalfWayTree
Paul,Nevers, Mazda HalfWayTree
Sandra,Rodgers, Kia Sportage,HalfWayTree
Charles,Browman, Honda Accord,UWI
John,Stewart, Toyota Corolla,UWI
Pat,Brown, Volkswagen Passat,UWI
Papine UWI
UWI Liguanea
HalfWayTree Papine
Papine UWI
UWI Liguanea
UWI HalfWayTree
Papine Liguanea
Papine HalfWayTree
Liguanea HalfWayTree
HalfWayTree HalfWayTree
HalfWayTree Liguanea
HalfWayTree Papine
HalfWayTree UWI
Liguanea Papine
Liguanea Liguanea
Papine UWI
UWI Papine
Liguanea UWI
Papine UWI
Papine Papine
Y
Y
Y
Y
Y
Y
Y
N
Y
N
Y
Y
Y
Y
Y
Y
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started