UMBC CMSC 202
UMBC CMSC 202 CSEE | 202 | current 202

CMSC 202 Spring 2005
Project 1

Rental Car Calculator

Assigned Wednesday February 16, 2005
Design Due Sunday February 20, 2005
Program Due Sunday February 27, 2005 at 11:59pm
Updates

Objectives


Project Description

This project begins the simulation of a car rental reservation system. This system will eventually consist of different kinds of cars to be rented and different kinds of renters.

In this first project, you will be asked to do some calculations related to renting a car. In particular, you will be calculating the car rental fee and the car insurance premium. These calculations are based on the tables below.

Car Rental Schedule


Weekly Charge Daily Charge Mileage Charge
GOLD Card Member $150.00 $30.00 First 200 miles FREE
$0.20 per mile over 200 miles
PLATINUM Card Member $100.00 $20.00 First 250 miles FREE
$0.12 per mile over 250 miles

Weekly Car Insurance Premiums


Under 25 25 and Over
GOLD Card Member $15.00 $10.00
PLATINUM Card Member $8.00 $6.00
Note - A full weekly premium must be paid for a partial week.
Insurance premiums are NOT prorated.

Your program will prompt the user for the following information, in the order specified.
  1. The renter's name -- two strings on the same line (first and last name) separated by one or more spaces
  2. The renter's age -- a positive integer which must be at least 18
  3. The renter's membership status -- either "GOLD" or "PLATINUM" (without the quotes)
  4. The renter's membership card number -- an integer between 1 and 999999, inclusive
  5. The car's model -- a string which may contain spaces
  6. The car's license tag number -- a (short) string with no spaces
  7. The number of days the car was rented -- a positive integer
  8. The number of miles the car was driven -- a positive integer
While you may assume the user will input the correct data type, your program must validate the input values where appropriate. If the user should input an invalid value, your program should immediately re-prompt for new input for that data item. DO NOT abort your program and DO NOT start re-prompting with the renter's name.

The output from your program must include all user inputs and the results of your calculations. You may provide any reasonable tabular output format. One possible format is provided here. Your output must meet the following requirements

  1. All money values must be output with 2 decimal places.
  2. All data must be labeled.
  3. Data must be separated into Renter, Car, and Cost Information sections as shown below.
  4. Renter names must be printed last name first.
  5. Card numbers must be formatted as 12-3456.
For purposes of formatting output only, you make the following assumptions
  1. The renter's first and last name total no more than 20 characters.
  2. The car's model is no more than 20 characters.
  3. The car's license tag number is no more than 8 characters.
  4. Days rented and miles driven are less than 10000.
  5. The total rental charge is less than $100000.
Renter Information ------ ----------- Name: Smith, Bob Age: 23 Card: 12-3456 / Gold Car Information --- ----------- Model: Nissan Z28 License: XY-1234 Days: 14 Miles: 345 Cost Information ---- ----------- Daily Charge: xxx.xx Mileage Charge: xxx.xx Insurance Charge: xxx.xx Total Charge: xxxxx.xx

Sample Calculations

Example 1

Let's say the Bob Smith (Gold card member, age 30) rents one of our cars for 10 days and drives 650 miles.

For purposes of rental calculations, 10 days = 1 week + 3 days
For purposes of insurance calculations, 10 days = 2 weeks

Daily Rental Cost = 150 + 3 * 30 = 240
Mileage Cost = (650 - 200) * 0.20 = 450 * 0.20 = 90
Insurance Cost = 2 * 10 = 20
Grand Total Rental Cost = 240 + 90 + 20 = $350

Example 2

Let say Mary Jones (Platinum card member, age 20) rents a car for 18 days and drive 880 miles.

For purposes of rental calculations, 18 days = 2 weeks + 4 days
For purposes of insurance calculations, 18 days = 3 weeks

Daily Rental Cost = 2 * 100 + 4 * 20 = 280
Mileage Cost = (880 - 250) * 0.12 = 630 * 0.12 = 75.60
Insurance Cost = 3 * 8 = 24
Grand Total Rental Cost = 280 + 75.60 + 24 = $379.60


Free Advice and Information

  1. The proper use and implementation of functions is an important part of this project (and your grade for this project). In particular,
    1. Your program must make adequate use of functions in keeping with top-down design principles.
    2. The names of the functions are left to you, but poor naming will lead to a losing points.
    3. Parameters must be passed to functions using the appropriate technique (by value, by reference, or by pointer). The proper use of const with parameters is also necessary.
    4. Values must be returned from functions appropriately.
  2. All functions called from main() must be implemented in a separate file named Proj1Aux.cpp. The prototypes for these functions must be found in a file named Proj1Aux.h.
  3. Your program must provide adequate error checking of user input.
  4. Your program must use const variables rather than "magic numbers" or "magic strings".
  5. Review the class notes on the different methods of passing parameters. Each is best for a different situation.
  6. Be sure your function header comments list the pre- and post-conditions and handle each pre-condition that is not met.
  7. Although not required, you may find the use of one or more structs helpful in organizing your data.
  8. Be sure to name your files as noted above, otherwise, you will have to modify the makefile we provide.
  9. Because your user will input strings that may contain spaces, the use of the ignore( ) function may be necessary. See the class notes on strings.
  10. Your program will be tested with a variety of good and bad inputs.
  11. Because your program will be test using Unix redirection, DO NOT prompt for any input not specified in the project description.
  12. Use incremental development.
  13. Get your project working with good input first. Then go back and put in the error checking and error handling.
  14. This project is approximately 175 - 200 lines of code... don't procrastinate.
  15. Ms Wortman's public directory for this project is /afs/umbc.edu/users/d/a/dana3/pub/CMSC202/p1.

Project Design Assignment

Your project design document for project 1 must be named p1design.txt. Be sure to read the
design specification carefully. Submit your design in the usual way: submit cs202 Proj1 p1design.txt

Project Makefile

The "make" utility is used to help control projects with large numbers of files. It consists of targets, rules, and dependencies. You will be learning about make files in discussion. For this project, the makefile will be provided for you. You will be responsible for providing makefiles for all future projects. Copy the file makefile from Ms. Wortman's public directory to your directory.

When you want to compile and link your program, simply type the command make or make Proj1 at the Linux prompt. This will compile all necessary .cpp files and create the executable named Proj1.

The make utility can also be used for compiling a single program without linking. For example, to compile Proj1.cpp, type make Proj1.o.

In addition to compiling and linking your files, make can be used for maintaining your directory. Typing make clean will remove any extraneous files in your directory, such as .o files and core files. Typing make cleanest will remove all .o files, core files, Proj1 executable and backup files created by the editor. More information about these commands can be found at the bottom of the makefile.


Grading

The grade for this project will be broken down as follows. A more detailed breakdown will be provided in the grade form you receive with your project grade.

85% - Correctness

This list may not be comprehensive, but everything on this list will be verified by the graders.

15% - Coding Standards

Your code adheres to the
CMSC 202 coding standards as discussed and reviewed in class.
In particular, since this is your first C++ program, pay particular attention to the list below. Graders will check all applicable items in the coding standards.
  1. Your file header comments
  2. Your function header comments (particularly pre- and post-conditions)
  3. Function and variable names
  4. In-line comments
  5. Code readability
  6. Limiting variable scope

Project Submission

Assuming you've used the recommended file names, then to submit your project, type the command submit cs202 Proj1 Proj1.cpp Proj1Aux.cpp Proj1Aux.h Makefile The order in which the files are listed doesn't matter. However, you must make sure that all files necessary to compile your project (using the makefile) are listed. You need not submit all files at the same time. You may resubmit your files as often as you like, but only the last submittal will be graded and will be used to determine if your project is late. For more information, see the projects page on the course website.

You can check to see what files you have submitted by typing

submitls cs202 Proj1

More complete documentation for submit and related commands can be found here.

Remember -- if you make any change to your program, no matter how insignificant it may seem, you should recompile and retest your program before submitting it. Even the smallest typo can cause compiler errors and a reduction in your grade.

Avoid unpleasant surprises!

Be sure to use the submitmake and submitrun utilities provided for you to compile, link and run your program after you've submitted it.


Last Modified: Monday, 28-Feb-2005 07:02:03 EST