Answered step by step
Verified Expert Solution
Link Copied!

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 7. 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 1 and display an appropriate error message. The appropriate error message is 'No driver available'.
Hackerrank Submission Instructions
For Problem 7, in the function , the parameters PassengerLocation and PassengerDestination will contain only one of the following, "UWI", "Papine", "Liguanea", "Half-Way-Tree". 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 (i.e. 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, Location-UWI/Papine/Liguanea/Half-Way-Tree)
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 information]-"Y" 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 2 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 3 lines are repeated based on the number of taxi requests.]
Sample Input 0
3
St. Johnnie,Dacosta,2005 Toyota Ipsum,UWI
Patricia,Palmer,2003 Volkswagen Passat,Liguanea
Maxine,Jones,2012 Volvo V60 Est,Half-Way-Tree
3
8761112222 Papine UWI
8451112222 UWI Liguanea
4444444 Half-Way-Tree Papine
2
44444441
87611122222
100
Y
Y
Y
Y
Y
Y
N
Sample Output 0
80.0
Enter "Y" to confirm the trip or "N" to cancel -No driver available
100.0
Enter "Y" to confirm the trip or "N" to cancel -90.0
Enter "Y" to confirm the trip or "N" to cancel -
Papine - Maxine Jones 1
Liguanea - Patricia Palmer 0
Liguanea - St. Johnnie Dacosta 1
Sample Input 1
12
St. Johnnie,Dacosta,2005 Toyota Ipsum,UWI
Patricia,Palmer,2003 Volkswagen Passat,Liguanea
Maxine,Jones,2012 Volvo V60 Est,Half-Way-Tree
Andrew,Zephers,2005 Suzuki Swift,Half-Way-Tree
Carlton,Rangers,2008 Subaru Legacy,Liguanea
Everton,Shroeter,2007 Nissan Tiida,Half-Way-Tree
George,Andrews,2003 Mitsubishi Spacewagon,Half-Way-Tree
Paul,Nevers,1999 Mazda 626,Half-Way-Tree
Sandra,Rodgers,2010 Kia Sportage,Half-Way-Tree
Charles,Browman,2003 Honda Accord,UWI
John,Stewart,2017 Toyota Corolla,UWI
Pat,Brown,2013 Volkswagen Passat,UWI
20
8761112222 Papine UWI
8451112222 UWI Liguanea
4444444 Half-Way-Tree Papine
8761112222 Papine UWI
8451112222 UWI Liguanea
8762223333 UWI Half-Way-Tree
8763334444 Papine Liguanea
8451112222 Papine Half-Way-Tree
8764445555 Liguanea Half-Way-Tree
3451119999 Half-Way-Tree Half-Way-Tree
8459991111 Half-Way-Tree Liguanea
8762224444 Half-Way-Tree Papine
8762223333 Half-Way-Tree UWI
8763339999 Liguanea Papine
8451112222 Liguanea Liguanea
8764445555 Papine UWI
8763334444 UWI Papine
8451112222 Liguanea UWI
8764445555 Papine UWI
8763334444 Papine Papine
10
44444441
87611122222
87622233332
87633344443
876444555510
87611111110
84511122220
84599911115
34511199991
11111111110
300
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

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

Database Systems For Advanced Applications 27th International Conference Dasfaa 2022 Virtual Event April 11 14 2022 Proceedings Part 2 Lncs 13246

Authors: Arnab Bhattacharya ,Janice Lee Mong Li ,Divyakant Agrawal ,P. Krishna Reddy ,Mukesh Mohania ,Anirban Mondal ,Vikram Goyal ,Rage Uday Kiran

1st Edition

ISBN: 3031001257, 978-3031001253

More Books

Students also viewed these Databases questions

Question

How can you defend against SQL injection attacks?

Answered: 1 week ago