Question: ( 6 0 % ) Write a program in which linked lists are used to maintain the data structure for a car rental company. The
Write a program in which linked lists are used to maintain the data structure for a car
rental company. The program allows several types of transactions to be applied to the data
structure in order to keep the lists uptodate.
In the program three linked lists are maintained for cars:
available for rent,
rented,
in repair.
The cars on the available list are ordered by mileage, with the car having the least miles at
the front of the list. The cars on the rented list are ordered by the expected return dates, with
the first car on this list having the earliest expected return date.
The program prompts the user for a transaction code integer as follows:
a add a new car to the availableforrent list,
b add a returned car to the availableforrent list,
c add a returned car to the repair list,
d transfer a car from the repair list to the availableforrent list,
e rent the first available car,
f print all the lists,
g quit.
For the new car addition and the return transactions codes the program should then
prompt for a plate number character string and a mileage integer For the transfer transaction code the program should then prompt for a plate number character string For
the rent transaction code the program should then prompt for an expected return date
integer: yymmdd For the print transaction code the program should not prompt any
additional information. The program should quit when the user selects in the prompter.
When a transaction is processed, a message should be printed indicating what action is taken,
for example which car is transferred from which list to which list. For each return transaction,
a charge is computed and printed as follows:
a flat rate of $ for up to km
cents per km for the additional ie beyond kilometres.
When a quit transaction is completed, the program prints the total income from all the rented
cars.
Also when a quit transaction is completed, the program should store the data into a disk file,
and when the program restarts, the program should read the data from the file and restore the
lists. Please create an initial disk file so that when the program starts for the first time, there
are data on the lists. The file should contain at least cars for each list.
Your program should be able to reasonably detect error conditions such as invalid transaction code, and an attempt to return a nonexistent car and print an appropriate error message.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
