1 EET110 BASIC COMPUTER PROGRAMMING MODULE 2
MODULE 2: DESIGNING PSEUDOCODE AND FLOWCHART
OBJECTIVES
1. To develop pseudocode and flowchart.
2. To trace pseudocode and flowchart in order to determine the contents of the variables
and the output.
3. To design pseudocode or flowchart with a given problem.
EXERCISE 1
Practice developing pseudocode.
1. Open the Microsoft Word software.
2. Type the following pseudocode.
Algorithm 2(a): Calculate total of two numbers.
Start
Set TOTAL to 0
Read Number1
Read Number2
Add Number1 and Number2 and store in TOTAL
Display TOTAL
End
3. Save the pseudocode file.
2 EET110 BASIC COMPUTER PROGRAMMING MODULE 2
EXERCISE 2
Practice developing flowchart.
1. Open the Microsoft Word software.
2. Create drawing canvas on the Insert menu, select Shapes and click New Drawing
Canvas.
3. Draw the following flowchart inside Drawing Canvas.
START
Read Number1
and Number 2
TOTAL = Number1 + Number2
Display TOTAL
END
Figure 2.1
4. Save the flowchart file.
Watch How to create a Flow Chart in Microsoft Word the right way by HBN Infotech
– Tutorials
[Link]
3 EET110 BASIC COMPUTER PROGRAMMING MODULE 2
EXERCISE 3
1. Write pseudocode as in Algorithm 2(b) that convert the distance in mile to kilometre.
Trace the content of the variables and determine the output.
Algorithm 2(b): Convert distance mile to kilometre.
Start
Set kmPerMile to 1.609
Set distanceMile to 100
Convert distance in mile to kilometre using formula
distanceInKilometre = kmPerMile x distanceMile
Display output of distanceInKilometre
End
2. Write pseudocode as in Algorithm 2(c) that assigns values to variables. Trace the
content of the variables and determine the output.
Algorithm 2(c): Determine the content of variables.
Start
Set Data1 = 5
Set Data2 = 2.5
Data3 = Data1 + Data2
Display Data1, Data2, Data3
End
3. Write pseudocode as in Algorithm 2(d) that reads the radius of a circle and calculates
the area of the circle.
Algorithm 2(d): Calculate the area of a circle.
Start
Set PI = 3.14159
Read the Radius
Calculate the area of circle using formula:
Area = Radius x Radius x PI
Display Area
End
4 EET110 BASIC COMPUTER PROGRAMMING MODULE 2
Trace the content of the variables and determine the output if the input of Radius is:
a. 5
b. 10
4. Write pseudocode as in Algorithm 2(e) that reads the money collection of a user. The
algorithm computes the number of Ringgit and cents (50, 20, 10, 5 and 1 cent) that can
be extracted from the collection. Tips: use the modulus operator.
Algorithm 2(e): Calculate Money change from
collection of Ringgit and cents
Start
Read the Collection
Determine total Ringgit using formula:
Ringgit = Collection / 100
Determine remain amount using formula:
remainAmt = Collection % 100
Determine total 50 cents in remaintAmt using formula:
fiftyCent = remainAmt / 50
Determine remain amount using formula:
remainAmt = remainAmt % 50
Determine total 20 cents in remaintAmt using formula:
twentyCent = remainAmt / 20
Determine remain amount using formula:
remainAmt = remainAmt % 20
Determine total 10 cents in remaintAmt using formula:
tenCent = remainAmt / 10
Determine remain amount using formula:
remainAmt = remainAmt % 10
Determine total 5 cents in remaintAmt using formula:
fiveCent = remainAmt / 5
Determine remain amount using formula:
remainAmt = remainAmt % 5
Determine total 1 cents in remaintAmt using formula:
oneCent = remainAmt
Display Collection, Ringgit, fiftyCent, twentyCent,
tenCent, fiveCent, oneCent
End
Trace the content of the variables and determine the output if the input of money
collection is:
a. 911
b. 1234
5 EET110 BASIC COMPUTER PROGRAMMING MODULE 2
EXERCISE 4
1. Draw a flowchart as in Figure 2.2 that calculates the payment for normal and overtime
working hours of an employee. Trace the content of the variables and determine the
output.
START
Set normalPayRate = 10.00
Set normalHours = 20
Set overtimePayRate = 5.00
Set overTimeHours = 8
Calculate totalPay = normalPayRate x normalHours +
overTimePayRate x overTimeHours
Display totalPay
END
Figure 2.2
6 EET110 BASIC COMPUTER PROGRAMMING MODULE 2
2. Draw a flowchart as in Figure 2.3 that calculates the total cost of the item purchased.
START
Read itemName
Read
pricePerUnit
Read Quantity
totalCost = Quantity * pricePerUnit
Read Payment
payChange = Payment - totalCost
Display itemName, Payment,
totalCost, payChange
END
Figure 2.3
7 EET110 BASIC COMPUTER PROGRAMMING MODULE 2
Trace the content of the variables and determine the output if the input values are as
follows:
a. itemName : Pencil
pricePerUnit : RM 0.40
Quantity : 12 unit
Payment : RM 10.00
b. itemName : Notebook
pricePerUnit : RM 3.00
Quantity : 7 unit
Payment : RM 50.00
8 EET110 BASIC COMPUTER PROGRAMMING MODULE 2
EXERCISE 5
Analyse each problem and identify the input, formula and the output. Write the pseudocode
and draw the flowchart for the problem.
1. Read four numbers then calculate the sum of the four numbers and find the average.
Display all the four numbers, as well as the total of those numbers and average.
2. Calculate the average weight of the three students. Display each student’s weight and
the average weight calculated.
3. Convert the time entered by the user in the form of day, hours and minute to minutes.
Display all time entered and converted minutes.
4. Convert the temperature entered by the user in the unit of Fahrenheit to the unit of
Celcius. The display input unit of Fahrenheit and converted unit in Celsius.