2. Prepared by: Dr. Yasmine Afify
Problem1
2
Write a pseudo-code for a program that displays the
bonus for employees according to the number of years
worked. The bonus is calculated as a percentage of the
current salary as shown in table. The output should be in
the following form:
The bonus is: 23.6 Bonus
Number of Years
5%
5
10%
10
15%
15
20%
Others
3. Prepared by: Dr. Yasmine Afify
Problem 1: Solution
3
BEGIN
READ years, salary
CASE OF years
= 5:
bonus = salary * 0.05
= 10:
bonus = salary * 0.1
= 15:
bonus = salary * 0.15
OTHERWISE
bonus = salary * 0.2
END-OF-CASE
PRINT “The bonus is: “ , bonus
END
4. Prepared by: Dr. Yasmine Afify
Problem 1: Another Solution
4
BEGIN
READ years, salary
IF years= 5 THEN
bonus = salary * 0.05
ELSE IF years= 10 THEN
bonus = salary * 0.1
ELSE IF years= 15 THEN
bonus = salary * 0.15
ELSE
bonus = salary * 0.2
END IF
PRINT “The bonus is: “ , bonus
END
5. Prepared by: Dr. Yasmine Afify
Problem 2
5
Write a pseudo-code for a program that reads the number of working
years and displays the celebrated company anniversary as shown in
table. The program should also display the raise amount for its
employees, which is calculated as 10% of the number of years the
company has been in business. The output should be in the following
form:
Silver
The raise is : 2.5 Anniversary
Number of Years
Bronze
10
Silver
25
Golden
50
Unknown
Others
6. Prepared by: Dr. Yasmine Afify
Problem 2: Solution
6
BEGIN
READ years
CASE OF years
= 10:
PRINT “Bronze”
PRINT “The raise is :” , 1
= 25:
PRINT “Silver”
PRINT “The raise is :” , 2.5
= 50:
PRINT “Golden”
PRINT “The raise is :” , 5
OTHERWISE
PRINT “Unknown”
END-OF-CASE
END
7. Prepared by: Dr. Yasmine Afify
Problem 2: Another Solution
7
BEGIN
READ years
IF years = 10 THEN
PRINT “Bronze”
PRINT “The raise is :” , 1
ELSE IF years = 25 THEN
PRINT “Silver”
PRINT “The raise is :” , 2.5
ELSE IF years = 50 THEN
PRINT “Golden”
PRINT “The raise is :” , 5
ELSE
PRINT “Unknown”
ENDIF
END
8. Prepared by: Dr. Yasmine Afify
Problem 3
8
Write the pseudo-
code for the
following flowchart,
which represents a
program that
calculates the
absolute difference
between two
numbers.
Which statement is
executed if the user
enters equal
START
Read x, y
IS
x < y
STOP
T
F
Print diff
diff= y - x
diff= x - y
9. Prepared by: Dr. Yasmine Afify
Problem 3: Solution
9
BEGIN
READ x, y
IF x < y THEN
diff = y - x
ELSE
diff = x – y
ENDIF
PRINT diff
END
START
Read x, y
IS
x < y
STOP
T
F
Print diff
diff= y - x
diff= x - y
If the user enters equal
numbers, the ELSE statement
is executed.
10. Prepared by: Dr. Yasmine Afify
Problem 4
10
Write the pseudo-
code for the
following flowchart,
which represents a
program that
calculates the net
salary of an
employee based on
his job: ‘M’ for
manager and ‘E’ for
employee.
Which statement is
executed if the user
enters ‘A’ ?
START
Read job
IS
Job =
‘M’
STOP
T
F
Print net
net = salary
+ bonus
net = salary
- tax
11. Prepared by: Dr. Yasmine Afify
Problem 4: Solution
11
BEGIN
READ job
IF job = ‘M’ THEN
net = salary + bonus
ELSE
net = salary - tax
ENDIF
PRINT net
END
If the user enters ‘A’, the ELSE
statement is executed.
START
Read job
IS
Job =
‘M’
STOP
T
F
Print net
net = salary
+ bonus
net = salary
- tax
12. Prepared by: Dr. Yasmine Afify
Problem 5
Draw a flowchart for the bank withdrawal process
represented by the following pseudo-code.
BEGIN
READ balance, withdrawal
IF withdrawal <= balance THEN
balance = balance - withdrawal
PRINT “Transaction Complete”
ELSE
PRINT “Insufficient Funds”
ENDIF
PRINT balance
END
13. Prepared by: Dr. Yasmine Afify
Problem 5: Solution
13
Bank Withdrawal Process
13
START
Read balance,
withdrawal
Withdrawal
< balance
STOP
T
F
Print
balance
Print
“Insufficient
Funds”
Print
“Transaction
Complete”
balance = balance
- withdrawal
14. Prepared by: Dr. Yasmine Afify
Problem 6
14
Draw a flowchart for a program that simulates the
doctor diagnosis. It reads a child temperature and
displays what a doctor would recommend in such
case. Doctors assume the child is healthy when his
temperature is below or exactly 37ºC. Therefore,
they recommend normal activities. However, if the
temperature is little higher than 37 ºC but still below
39 ºC, then the doctor recommends careful
observation. Otherwise, the doctors recommend that
the child should be admitted to hospital.
15. Prepared by: Dr. Yasmine Afify
Problem 6: Solution
15
START
Read temp
IS
temp <=
37
STOP
T
F
Print “Careful
Observation”
Print “Normal
Activities”
IS
temp <=
39
T
F
Print “Admitted
to Hospital”