4. Car Rental

  • Feel free to use your laptop if you have it

  • Ensure I have recorded your completion — failure to do so will result in a grade of 0

  • I strongly encourage you to work with others in the lab

    • When you get stuck, do me a favour and ask those sitting around you for help

    • I want people to get used to working together in the labs

    • Peer teaching and peer learning is super effective


To obtain full marks for the lab, you must:

  1. Have been working on the lab content

  2. Demonstrate competency in the topics

4.1. Pre Lab Exercises

  • There are no exercises to complete before this lab

4.2. Before Kattis


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.


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.


  • 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

4.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


Ensure that your your completion has been recorded. Failure to do so may result in a grade of 0.