5. Car Rental

  • Feel free to use your laptop

  • You are strongly encourage to work with others

    • When you get stuck, ask those sitting around you for help

    • Get used to working together in the labs

    • Peer teaching and peer learning has been empirically shown to be very effective

5.1. Pre Lab Exercises

  • There are no exercises to complete before this lab

5.2. Before Kattis

../../_images/carRental.png

A car rental place needs our help. They want a program to calculate how much a customer is to be charged based on their rental agreement, age, how far they drove, and how long they had the car.

Note

Obviously this is directly from lecture. Do not just copy/paste the solution — take this as an opportunity to re-implement the solution from scratch while taking care to truly understand what is going on. In fact, I will be very happy if you have slightly different solutions than what I provided in lecture. Use this lab to work out what you understand in the course and what you don’t quite understand yet.

Rules:

  • We will get and record the customer’s:

    • Age

    • Rental agreement classification code (B or D)

    • Number of days rented

    • Starting odometer reading

    • Ending odometer reading

  • If the classification code is B

    • Base charge of $20.00/day

    • Plus $0.30 for every km driven

  • If the classification is D

    • Base charge of $50.00/day

    • Plus $0.30 for every km driven above the 100km/day average allowance

  • All renters under the age of 25 are charged an additional $10.00/day

5.3. Kattis Problems

  • Work on the Kattis problems you have not solved from previous weeks

  • Remember, I encourage you to work with others to solve the problems