Car rentals Download

Dave Wittry

if statements, for loops, strings, mods Student approved


When you rent a car from an agency, the key ring has several pieces of information: license plate, make and year of car, and usually a special code. This code could be used for some data processing within the company's computers.

This lab will practice determining that special car rental code from the license plate.


Here's how to convert a license plate into a car rental code:

  1. Ask the user for a license plate. A license plate consists of digits and capital letters of the alphabet only, like 607CPR21, 123ABC4567, 1F24, or 98ZWXTY2.
  2. Add up the ASCII values of the letters and the integer values of the digits, e.g.6 + 0 + 7 + 67 + 80 + 82 + 2 + 1 = 245 for our first example above.
  3. Take this sum and map it onto a numeric representation of one of the 26 letters of the alphabet (where A’s numeric representation is 0, B’s numeric representation is 1, etc.). For example, 245 should map to an 11.
  4. Use this number (say 11) to determine the 11th letter in the alphabet after the letter A: the 11th letter after A is L.
  5. Combine the letter and the sum to make the car ID. So far, it's: L245.
  6. Extract the substring of letters out of the original license plate – in this case CPR. Convert the letters to lowercase and place the letters at the end of the car id to get – and print – the final answer: L245cpr

Starter code

class Plate{

Expected output

Plate 607CPR21 = L245cpr

Useful tools to solve the problem