PSPD Lab 3C
PSPD Lab 3C
PSPD Lab 3C
Learning Outcomes
This lab activity encompasses activities 3C.1, 3C.2, 3C.3 and 3C.4
CASE STUDY
Infinity Design Solution Sdn. Bhd, an advertising company wants to automate the system of managing Human
Resources (HR) data. Cik Suria was selected to be an IT programmer for Infinity Design Solution. En. Mohamed
insist to develop a system to manage staff payroll. Cik Suria has to prepare a proposal for payroll system.
INSTRUCTION:
1. Illustrate the flow of control structure using pseudocode and flow chart in design system.
Activity 3C.1
Activity Outcome: Write pseudo code and flowchart for selection control structure in solving given problems.
Duration : 45 minutes
Based on the problems given, write the pseudo code and flowchart for selection control structure.
1. Program that receives the current temperature as input. If the temperature is 80 degrees or more, output
a message telling the user to go swimming, otherwise, if the temperature is 50 degrees or more, output
a message to go running, otherwise stay inside.
a. Pseudo Code
Start
Enter temp
if (temp >= 80)
Display "Go take a swim! "
else if (temp >= 50 && temp < 80)
Display "Go take a run! "
else
Display "Stay inside! "
EndIf
End
b. Flowchart
2. Jusco Supermarket is now offering some discount on selected items for Carnival Mega sale. Help the
supermarket cashiers to calculate the net price of the selected product’s below.
Position Discount
1. Food Item 5%
2. Health Item 6%
3. Electric Item 9%
4. Cloth Item 4%
a. Pseudo code
Start
Enter Quant1,Quant2,Quant3,Quant4
Enter PriceItem1,PriceItem2,PriceItem3,PriceItem4
tot_disc1=[(Quant1*PriceItem1)*0.05]+(Quant1*PriceItem1)
tot_disc2=[(Quant2*PriceItem2)*0.06]+(Quant2*PriceItem2)
tot_disc3=[(Quant3*PriceItem3)*0.09]+(Quant3*PriceItem3)
tot_disc4=[(Quant4*PriceItem4)*0.04]+(Quant4*PriceItem4)
net_Price=tot_disc1+tot_disc2+tot_disc3+tot_disc4
Display net_Price
End
b. Write a Flowchart
1. Initialize Counter = 1; average = 0; Total = 0;
2. Input number.
3. Add Total using formula:
Total = Total + number
4. Add Counter using formula:
Counter = Counter + 1
5. Compare whether Counter is greater than 5.
If yes, go to step 6.
If no, go to step 2.
6. Calculate Average of numbers using formula:
Average = Total / 5
7. Display Average.
Activity 3C.2
Activity Outcome: Write pseudo code and flowchart using repetition control structures in solving given
problems.
Duration : 45 minutes
1. Based on the algorithm below, prepare a pseudo code and flowchart for each type of repetition control
structures.
a. Pseudo code:
For Loop
Start
Average = 0
Total = 0
For (i=1; i <=6; i++)
Input Num
Total=Total+Num
EndFor
Average=Total/5
Display Average
End
While Loop
Start
i=1
Average = 0
Total = 0
While ( i<=6)
Input Num
Total=Total+Num
i=i+1
EndWhile
Average=Total/5
Display Average
End
Do..While Loop
Start
i=1
Average=0
Total=0
Do {
Input Num
Total=Total+Num
i=i+1
} While (i<=6)
Average=Total/5
Display Average
End
b. Flowchart:
Input Mark
Process
Average=total/10
Pseudo code:
Start
i=0
total=0
Average=0
While (i<10)
Input Mark
Total=Total+Mark
i=i+1
EndWhile
Average=Total/10
Display Average
End
Flowchart:
START
i=0
To ta l=0
Ave ra g e =0
NO
i<10
YES
Ave ra g e =To ta l/ 10
In p ut
m a rk
Disp la y
Ave ra g e
To ta l=To ta l+Ma rk
END
i=i+1
Activity 3C.3
Activity Outcome: Design the pseudocode and flowchart for a given case study using problem solving tools.
Duration : 45 minutes
1. A car park has the following charges. The 1st hours cost RM2.00. The sub sequent hours cost RM1.00
per hour. Design the algorithm for this problem and draw flowchart using problem solving tools.
FLOW CHART
START
i=0
Total=0
Average=0
N
i<10
YE Total_salary=(total*0.1)+tota
S l
Input
hour
Average=Total/10
Salary=hour*8 Display
Average
Total=Total+Salar
y
END
i=i+1
2. Calculate the salary that employee get based on number of working. Rate of the payment is RM8.00
per hour but the salary will be deducted with 10% KWSP. By using a repetition control structure, write
pseudo code and design a flowchart using problem solving tools to calculate the total salary of 5
employees and the average salary of the employee.
Start
i=0
total=0
average=0
For (i=0;i<10;i++)
Enter hour
Salary=hour*8
total=total+salary
EndFor
Total_salary=(total*0.1)+total
Average=Total_salary/10
Display Average
End
illustrate flow of control structure in a program.
Case Scenario
Activity 3C.4
Activity Outcome: System design (write pseudocode and darw flowchart)
Duration : 45 minutes
PROBLEM
Case Senario:
The system will automate the process of calculate payroll for employees worked at Infinity Design Solution Sdn. Bhd.
Each employee will be recognized by employee ID. The system will receive gross income, allowance, overtime, income
tax and loan deduction. The system will automatically calculate the total income, total deduction and net salary for the
employee.
Pseudocode Flowchart
Start
Input gross_income,allowance,overtime,income
tax,loan_deduct.
Display net_income
End