- The department of History has just bought a new photocopier. Any person using the photocopier must enter an identification code. You have been asked to do the following:
- Write a program that determines whether identification codes typed by users of a photocopier are valid, and prints appropriate messages. If the identification code, which is a four-digit number, is correct your program computes the cost of copying according to the table below.
- Your program should prompt the user for an identification code, read it and determine whether it is valid. An identification code is valid if its rightmost digit is correct. A correct digit is equal to the remainder of the sum of the other three digits divided by 7. For example, a valid code that gives a correct digit is 7011. However, 9999 is not a valid code. 7011 is a valid code because (7+0+1)%7 = 1, which is equal to the rightmost digit of 7011. But 9999 is not a valid code because (9+9+9)%7 = 6, which is not equal to the rightmost digit of 9999.
Correct digits are assigned as follows:
Student: 1, 2 (means 1 or 2)
Teacher: 3, 4, 5
Secretary: 6
Others: 7, 8, 9
Number of pages |
1 to 10 |
10 to 20 |
>20 |
Students |
0.10 Dhs |
20% off |
40% off |
Teachers |
0.30 Dhs |
30% off |
40% off |
Secretaries |
0.20 Dhs |
25% off |
40% off |
Others |
0.60 Dhs |
10% off |
20% off |