Thursday, 9 July 2015

car rental company

Order this paper @Essaybay.net...The Best Custom Essay writing service globally
NOTE: Remember that you areNOTallowed to use thebreak, return,orexitstatements toexit from a loop. All loops must exitONLYvia theirtest condition.
Program #1
The car rental company would like you to write a program to calculate and print their car
rental bills. You will also write a test plan to test the program.
This rental car company has four sizes of cars. The customers can rent acompact,mid size,full size,orSUVcar at the following rates:
Car CarCharge Daily Rate
Size(1-6 days)
Compact $ 22.91
Mid size $25.76
Full size $ 28.87
SUV $ 98.88
Cars rented for 7 or more days are charged a lower weekly rate for whole weeks. The discountis applied to the daily rate.
Car Charge Weekly Rate (for 7 days):6.5 x Daily Rate
Rate Examples: 12 days = 1 x weekly rate + 5 x daily rate
14 days = 2 x weekly rate
15 days = 2 x weekly rate + 1 x daily rate
Some mileage is included, but customers must pay for any mileage over the allowance:
Car Mileage Cost per
Size Included (per day) Mile for Overage
Compact 20 miles 5 cents
Mid size 25 miles 7 cents
Full size 30 miles 9 cents
SUV unlimited none
All car rentals are also subject to a 11.5% tax on the full charge, including mileage.
Implementation Details
Define constants for all fixed values and usedoubleprecision floating point variables for alldollar& cents figures.
First explain what the program will do.
Then call auser-definedfunction to read and validate the car size. Display a menu of car sizes,along with daily costs of each, to the user. Prompt for the car size (C, M, F, or S), and errorcheck that the user has entered a valid choice (accepted in upper or lowercase). Re-prompt untila valid choice is entered. Return the validated choice inuppercase.
Next call auser-definedfunction to read and validate the number of days rented, as describedbelow. Days rented will be whole numbers, and will be at least 1.
If necessary (for all car sizes, except SUV), call thesameuser-definedfunction again, to readand validate the miles driven. Miles driven will be whole numbers, and will be at least 1.
Call auser-definedfunction to calculate the bill components and the bill total. This functionwill call two otheruser-definedfunctions, as described below.
Display a couple of blank linesafterall input has been entered andbeforethe bill output isdisplayed. Call auser-definedfunction to display the output.
The output should first display a summary of the rental: the car size in words, the days rented,and the miles driven (unless SUV). Then the bill should be output, including lines for the totalcar charge, the mileage charge (unless 0), the tax, and the grand total.
After displaying the results, ask the user whether to execute the program again, and do so, aslong as the user wishes to continue. Be sure to error check the user s answer is valid, and loopuntil a valid answer is entered (as part of implementing nested loops).
At aminimum, the program must implement the following functions (in addition tomain):
One function to read and validate the car size choice.
One generic function to read and validate that a number entered is 1 or more. Thisfunction should have a string parameter, identifying the value to be read (to be used inprompts and error messages). Loop and re-prompt until a valid value is entered.
One function to calculate the total car charge.
One function to calculate the mileage charge.
One function to calculate the bill amounts. This function should call the previous twofunctions, and should pass the car charge, the mileage charge, the tax and the grandtotal back tomainviareferenceparameters.
One function to display the output.
Use of global variables isNOTallowed. The functions must useparametersto pass requireddata to each function.
Remember to pass allinputonly parametersby value, and pass alloutputparametersbyreference.
Output parameters shouldonlybe used whenmore than onevalue is being passed backfrom main. For onlyonevalue, use thereturnstatement.

No comments:

Post a Comment