Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Task 1 : Checksum for Singapore car license plate number [ Total: 7 0 marks ] A Singapore car license plate, such as SHA 4

Task 1: Checksum for Singapore car license plate number [Total: 70 marks]
A Singapore car license plate, such as SHA4022, E43A , etc., consists of the following:
Prefix consisting of alphabets.
E. SHA, SGJ, QX, FBB, E
Numerical series from 1-9999, without leading zeros
E.g.10,402,2222
Checksum letter, one of these 19 letters: (A, Z, Y, X, U, T, S, R, P, M, L, K, J, H, G, E, D, C, B)
The checksum letter of a license plate validates if that license plate is valid or not.
In this task, write a program to calculate the checksum letter given a Singapore vehicle licence plate.
Here is the formula for calculating the checksum letter'
The last 2 letters of the prefix are converted into digits, where A=1,B=2,dots, and Z=26.
If there is only 1 letter, then convert that letter into digit, and add a digit 0 to the front.
E.SBS=2 and 19,SH=19 and 8,E=0 and 5
Add leading zeros to the numerical series to make it a 4 digit figure.
E.e.100010,4020402,22222222(no change)
Combine the prefox digits and the numerical series to form a series of six numbers.
E. S. SSS10=>[2,19,0,0,1,0]
Each individual numbers are then multiplied by the corresponding position of the six fixed numbers
(9,4,5,4,3,2)
E.g. S8S10->{2,19,0,0,1,0]*(9,4,5,4,3,2]=[18,76,0,0,3,0]
The multiplied numbers are then added up E.g.(18,76,0,0,3,0)97
Oivide the sum by 19 and get the remainder.
E.g.9719=5 remainder 2
The remainder corresponds to one of the 19 letters (A. Z, Y, X, U, T, S, R, P, M, L, K, J, H, G, E, D,
C. B) where remainder 0 corresponds to 'A', remainder 1 corresponds to Z' and so on.
E.g. Checksum letter for remainder 2=*.
Task 1a [10 marks]
Write a function alphabet_to_digit (c). This function takes in an alphabet and converts it into its digit
representation where A=1 and Z=26. Your function should be case insensitive, ie., to handle both upper
and lower case alphabets.
Note: You are strongly encouraged to use comments to describe your code where necessary.
Task 1b [10 marks]
Write a function convert_pref 1(prefix). This function takes in a non-empty alphabet string called
prefix and returns a list of two integers, which are the converted digits of the last two alohabets in orefix.
For our question, we do not limit the number of alphabets in a prefix. i.e. The prefix can be
"SBSBCSBSDBSZBS", but still only the last two characters are taken for conversion.
. i.e.'SBSBCDZBS' should return 2,19 and 'E' should return 0,5
Note: You are strongly encouraged to ure comments to describe your code where necessary.
Task 1c [10 marks]
Write a function convert_num_series (num_series). This function takes in a non-empty string of at
most four digits (a number from the numerical series) and returns a list of integers representing exactly 4 Note: You are strongly encouraged to use comments to describe vour code where necessary.
Task 1c [10 marks]
Write a function convert_num_series (num_series). This function takes in a non-empty string of at
most four digits (a number from the numerical series) and returns a list of integers representing exactly 4
digits.
i.e.'10' should return 0,0,1,0 and '2222' should return 2,2,2,2
Note: You are strongly encouraged to use comments to describe vour code where necessary.
Task 1d [10 marks]
Write a function multiply_and_add(series). This function takes in a list of six integers and multiplies
each integer with the corresponding number in 9,4,5,4,3,2 to obtain a new list of six integers; it then
returns the sum of these integers.
Note: You are strongly encouraged to use comments to describe vour code where necessary.
Task 1e[10 marks]
Task 1e: Write the function remainder_to_checksum_letter(remainder) that takes in an integer
checksum remainder (ranging from 0 to 18) obtained in step 6 of the formula and returns the
corresponding checksum letter (in uppercase).
i.e.0 should return 'A' and 18 should return 'B'.
Note: You are strongly encouraged to use comments to describe your code where necessary. Task 1f
Complete the function checksum_calculator (plate) by putting everything together and returning the
checksum letter in uppercase given a license plate. Reminder: 1. Your program should be able to handle
lowercase inputs. 2. The prefix
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Databases New Opportunities For Connected Data

Authors: Ian Robinson, Jim Webber, Emil Eifrem

2nd Edition

1491930896, 978-1491930892

More Books

Students also viewed these Databases questions

Question

A. $7,653.24 B. $4,059.40 C. $12,312.35 D. 510,705.77

Answered: 1 week ago

Question

What is meant by organisational theory ?

Answered: 1 week ago

Question

What is meant by decentralisation of authority ?

Answered: 1 week ago

Question

Briefly explain the qualities of an able supervisor

Answered: 1 week ago

Question

Define policy making?

Answered: 1 week ago

Question

Define co-ordination?

Answered: 1 week ago