Aaon A. Santillan Computer Programming I BSCS1 1N

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Aaon A.

 Santillan  Computer Programming I
BSCS1­1N

6. Write an algorithm that reads three numbers and prints the value of the
largest number

Algorithm:

Step 1: Input N1, N2, N3


Step 2:
if (N1>N2) then
if (N1>N3) then
N1[N1MAX >N2, N1>N3]
else
N3[N3MAX >N1>N2]
endif
else
if (N2>N3) then
N2[N2MAX >N1, N2>N3]
else
N3 [N3MAX >N2>N1]
endif
endif
Step 3: Print “The largest number is”, MAX
Flowchart:
7. Write and algorithm and draw a flowchart to :
a) read an employee name (NAME), overtime hours worked
(OVERTIME), hours absent (ABSENT) and
b) determine the bonus payment (PAYMENT).

Algorithm:

Step 1: Input NAME,OVERTIME,ABSENT


Step 2: TOTALHOURSWORKEDOVERTIME–(2/3)*ABSENT
Step 3: if (TOTALHOURSWORKED > 40) then
50PAYMENT
else if (TOTALHOURSWORKED > 30) then
40PAYMENT
else if (TOTALHOURSWORKED > 20) then
30PAYMENT
else if (TOTALHOURSWORKED > 10) then
20PAYMENT
else
10PAYMENT
endif
Step 4: Print “Bonus for”, NAME “is $”, PAYMENT
Flowchart:

You might also like