Chapter 2: Problem Solving. Software development method specification of needs problem analysis design and algorithmic representation implementation testing and verification documentation. Introduction to Problem Solving.
age = today’s date - birth date
if age > 55
print “sudah pencen”
print “kerja lagi”
while user still wants to play
Select either to play on network or play against computer
if play on network
create connection to remote machine
play game with connected computer
play game locally
Ask user whether he/she still wants to play
end points of an algorithm.
Process symbol - shows an instruction other than
input, output or selection.
Input-output symbol - shows an input or an output
Disk storage I/O symbol - indicates input from or
output to disk storage.
Printer output symbol - shows hardcopy printer
for two-way selection.
Off-page connector - provides continuation
of a logical path on another page.
On-page connector - provides continuation
of logical path at another point in the same
Flow lines - indicate the logical sequence of
execution steps in the algorithm.
Play on network?
You are required to develop a complete system which will enable the sum of two values to be calculated.
What do we have to do first?
The unit for electricity usage is kWh. For domestic usage, the tariff used is tariff A. The monthly rate for tariff A is 21.8 cents/unit for the first 200 unit, 25.8 cents/unit for the next 800 units and 27.8 cents/unit for each additional units. Given the amount of electricity units (in kWh) used by a customer, compute and print the amount of money needs to be paid by the customer to TNB.
Print “Enter the usage (unit): ”
if (usage > 200)
payment = 200 x 21.8
usage = usage – 200
if (usage > 800)
payment = payment + (800 x 25.8)
usage = usage - 800
payment = payment + (usage x 27.8)
payment = payment + (usage x 25.8)
payment = usage x 21.8
Print “Total payment is “, payment
This program will calculate the total tuition fee for a UNITEN student. The program ask for total number of subject registered. Then it will ask for the number of credit hours for each subject. The program will print out the total tuition fee in RM. Assume that tuition fee is RM300 per credit hour
Print “Enter total number of subject: “
counter = 0
totalFee = 0
while (counter < totalSubject)
Print “Enter the number of credit of the subject: “
totalFee = totalFee + (credit x 300)
counter = counter + 1
Print “The total fee is “, totalfee
1. Write pseudocode of a program that calculate the total sum of series starting from 1 to a number specified by user. Example, if user input 4, the result is 1+2+3+4=10.
2. Write pseudocode of a program that will print the net income of a salesman in ABC Bhd given the total sales of a month. The basic salary is RM500. The commission is 5% of the first RM50,000.00 sales, 10% for next RM200,000.00 sales and 20% for the remaining. A sum of 11% of the gross income will be deducted for KWSP contribution.
Print “Enter last number in the series: “
counter = 1
sum = 0
while (counter<=lastNumber) do
sum = sum + counter
counter = counter + 1
Print “The sum of the series is “, sum
Print “Enter monthly sales: “
income = 500
income = income + (0.05 x 50000)
sales = sales - 50000
income = income + (0.1 x 200000)
sales = sales - 200000
income = income + (0.2 x sales)
income = income + (0.1 x sales)
income = income + (0.05 x sales)
income = income – (income x 0.11)
Print “The net income is “, income