Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
STUDIES
TOTAL MARKS
LECTURER COMMENTS:
PROBLEM DEFINITION
IPO CHART
Output netSalary
Start
Display “Enter Basic Salary”
Read basicSalary
EPF = 9 / 100
SOCSO = 2 / 100
If (basicSalary >= 2500)
Display “Enter House Allowance”
Read houseAllowance
Display “Enter Telephone Allowance”
Read telephoneAllowance
Display “Enter Transportation Allowance”
Read transportationAllowance
totalAllowances = houseAllowance + telephoneAllowance + transportationAllowance
grossSalary = basicSalary + totalAllowances
totalContribution = EPF * grossSalary
Else
(basicSalary <= 2000)
grossSalary = basicSalary
totalContribution = (EPF + SOCSO) * grossSalary
EndIf
netSalary = grossSalary - totalContribution
Display “The net salary is :” +netSalary
End
FLOWCHART
TRACE TABLE
EXPECTED SCREEN
Design an algorithm for a program that displays the menu below. The program should
ask the user to enter a choice, then the selected operation will be performed. Each
operation will receive inputs and display the output.
Choice Operation
----------------------------------------------------------------------------------------------------
C Calculate the area of a circle
T Calculate the perimeter of a triangle
R Calculate the area of a rectangle
S Calculate the volume of a cylinder
PROBLEM DEFINITION
IPO CHART
areaOfCircle
Output perimeterOfTriangle
areaOfRectangle
volumeOfCylinder
PSEUDOCODE
Start
Display “Enter choice”
Read choice
If (choice = “c”)
Display “Enter Radius”
Read radius
areaOfCircle = 3.142 * radius ^ 2
Display “c is :” +areaOfCircle
Else
If (choice = “t”)
Display “Enter Side A”
Read sideA
Display “Enter Side B”
Read sideB
Display “Enter Side C”
Read sideC
perimeterOfTriangle = sideA + sideB + sideC
Display “t is :” +perimeterOfTriangle
Else
If (choice = “r”)
Display “Enter Length”
Read length
Display “Enter Width”
Read width
areaOfRectangle = length * width
Display “r is :” +areaOfRectangle
Else
If (choice = “s”)
Display “Enter Radius”
Read radius
Display “Enter Height”
Read height
volumeOfCylinder = 3.142 * radius ^ 2 * height
Display “s is :” +volumeOfCylinder
EndIf
End
FLOWCHART
TRACE TABLE
EXPECTED SCREEN
Enter choice = c, t, r, s
Enter radius = 2
Enter sideA, sideB, sideC = 2,2,2
Enter length = 4
Enter width = 2
Enter heigth = 4
The area of circle is = 7.142
The perimeter of triangle is = 6
The area of rectangle is = 8
The volume of cylinder is = 50.272