You are on page 1of 3

Advanced Programming (0303204)

EX01:

Program A (100%): Calculation an audit report of a Palestinian ID number

A Palestinian identity card number is a number given to every Palestinian citizen on the day of his birth.
This number is a unique value, and each person in Palestine holds a unique ID, unique value, which
cannot be given to anyone other than him.

When the computer entered government ministries and the Interior Ministry in particular, it was
necessary to avoid typing errors of ID number. To this end, the critique story was created, a story that
sits on the right side of the number, and represents the result of some computational algorithm. When a
typing error occurs, the computer program alerts you and the typed number is corrected accordingly.

Algorithm: Checking the integrity of the audit report

A. Write the ID number in 9 digits, if the ID number is less than 9 digits, complete leading zeros on the
left side of the number

012345674

B. Below each digit of the ID number, write from the right side of the number the digits 1, then 2, then
again 1, then again 2 and repeat until the end. These numbers are called weights.

012345674

121212121

C. Multiply by an abbreviated multiplication, without bearing any digit in the ID number with the digit
below it (weight). The result, even if it is in two digits, is written below a third line.

012345674

121212121

0 2 2 6 4 10 6 14 4

D. The results become the results of one digit. For example, if a result is a two-digit number, add all the
digits of the number to one digit. For example, add the result 14 as 4 and another 1, and get 5. The
result 10 add about 1 and another 0 and get 1. All the results are written in a fourth row.

012345674

121212121

0 2 2 6 4 10 6 14 4
022641654

E. Now, connect all the digits in a simple arithmetic addition until a result is obtained. The result must be
a number divisible by 10 with no remainder, meaning that its unity number is 0.

012345674

121212121

0 2 2 6 4 10 6 14 4

022641654

0 + 2 + 2 + 6 + 4 + 1 + 6 + 5 + 4 = 30

F. A result that is not divisible by 10 with no remainder indicates a number that is incorrect within the ID
number (typing incorrectly, for example). A result that is divisible by 10 with no residual indicates a valid
ID number.

General Comments:

A. The user should be instructed as to what input is expected of him, and that informative output should
be presented.

B. When you need to display a number of data in some row in the output separate them using a single
space.

C. Maintain a programming style, especially:

1. Documentation of all its components.

2. Layout.

3. Variable names.

Submission Procedure:

- Put your programs with names EX01.java files in a directory named lab0
- Upload a zipped file lab0.zip or EX01.rar
- Your program file will include a title with the following: course name, year and semester, exercise
number, program topic, student name. for example:

modprog1, 2006a

EX# 8a: A program that sends a spaceship to the moon

Written by: Hana Hirbawi,

id: 333444555,

You might also like