I need help to get this program done here is the problem: The purpose of this pr
ID: 3620898 • Letter: I
Question
I need help to get this program done here is the problem:The purpose of this program is to simulate the operation of a taxi company that
serves customers around town and to generate a report that summarizes the operation of the
company. For this assignment, the company only owns one cab. Initially, the cab parks at the
location (0, 0) with no passenger on board. It has full tank (20 gallons) of fuel and its gas
mileage is 30 mpg without any passenger (the driver only). Each on board passenger will reduce
the gas mileage by 5%. For example the gas mileage changes as the following table.
Number of passenger Gas mileage (mpg)
0 30.0
1 30*95%=28.5
2 30*90%=27.0
3 30*85%=25.5
4 30*80%=24.0
5 30*75%=22.5
Whenever there is a new customer request and the cab is not serving any customer request, then
the cab will be dispatched to the customer’s location to pick up some passengers and drive them
to the destination. Before driving to any location, the cab will fill the gas tank to its capacity if it
finds it cannot reach the destination with the remaining fuel – i.e., it will compute the amount of
fuel needed to drive to the destination, and it will fill up the gas tank if it doesn’t have enough
gas.
The cab’s location, customer’s location and customer’s destination are denoted by x- and ycoordinates.
In this program, customer requests are stored in an input file (eg, “request.dat”). You should
read the input file name interactively and check for the file existence. The cab is required to
serve customer requests in the same order as they are listed in the data file. Each line of the data
file has the following information in the given order:
customer_id x-origin y-origin x-destination y-destination number-of-passengers
Output:
• Print information for the following activities. All information should be clear and
accurate.
o receiving a customer request, print customer id, # of passengers, location of
customers, and destination of customers
o passenger loading: print the number of customer on board
o passenger unloading: print the number of customers unloaded
o whenever the cab moves one location to another location: print the following
information
?? gas consumed during the trip
?? miles of the trip
?? gas remained after the trip
?? total miles traveled so far after the trip
?? total gas consumed so far after the trip
Assumption:
• The company operates one cab.
• Initially all cabs are parked at the location (0, 0) with no passenger on board. It has full
tank (20 gallons) of fuel.
• Each customer request has up to 5 passengers.
• One tank of gas is enough for the cab to drive from the current location to the customer’s
location, or from the customer’s location to customer’s destination.
• x- and y-coordinates are integers.
• The cab will not go back to the company’s location (0,0) after serving a customer request.
There are enough gas stations scattered throughout the district so that the driving distance
(and gas consumed) from anywhere in the area to a gas station can be omitted during the
calculation.
Class Design:
A cab used in this program is an instantiation of Vehicle class. Use the following class diagram
that defines this class (You may add more methods and/or data members as needed.).
Vehicle
- passenger: integer
- remainingFuel: double
- totalMilesTraveled: double
- totalFuelConsumed: double
- x: int
- y: int
+ Vehicle()
+ pickupCustomer(int, int, int)
+ dropoffCustomer(int, int)
- moveTo (int, int)
- loadPassenger (int)
- unloadPassenger ()
- fillUpGas ()
Notes: + means public member and – means private member
Explanation / Answer
Exactly what is your question or were you hoping to have someone do your homework for you? If so, you should probably ask yourself what exactly is your purpose in taking the class. Anyway, the general way you solve these programming assignments is to break them down into smaller pieces. You're going to want to turn off the video games, the TV or whatever else you use to entertain yourself ;) Then take out a notebook, a pencil and eraser. Start by writing down the main points of the assignments. Draw pictures. Do whatever you need to understand the general idea of what your program does. A good way to get started is to think of the inputs and outputs and how you get from one to the other. A flow chart is good if you can make one. You should now have a bunch of general statements, sentences, pictures whatever. The verbs are going to be your functions. The quantities are going to be your variables... If you get stuck, then come back and ask that specific question. If you completely hate doing the above. You're probably not going to like computer science in general as I can promise you it doesn't get easier.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.