You are on page 1of 5

ASSIGNMENT 1 (10%)

Problem solving techniques – Selection /Decision -IF


 Please refer to reference/lab book.

1. Page 28 no3 and no4


2. Page 38, no2 
3. Page 42, no5 (for  i and ii only)

INSTRUCTION:
Please:

1. Clear understand on the problem determination


2. Write analysis of IPO - when necessary
3. Develop the algorithm (graphically) - when necessary 
4. Answer all questions
5. Print out and send the hard copy at my room 
6. DUE: 10 APRIL 2019
Page no28, no3

Output: minutes
Input: days, hours and minutes
Formula: minutes = 24 hours * 60 minutes

Pseudo code design of the problem

1. Start
2. Set 1 days
3. Set 24 hours
4. Set 60 minutes
5. Convert days, hours and minutes to minutes using the formula:
minutes = 24 hours x 60 minutes
6. Display the times in minutes
7. End

Flowchart design of the problems

START

Set 1 day
Set 24 hours
Set 60 minutes

minutes = 24 hours * 60 minutes

Display the
times in
minutes

End
no4

Output: Celsius
Input: Fahrenheit
Formula: Celsius = (Fahrenheit - 32) * 5/9

Pseudo code design of the problem

1. Start
2. Set Fahrenheit
3. Convert Fahrenheit to Celsius using the formula:
Celsius = (Fahrenheit - 32) * 5/9
4. Display the temperature in Celsius
5. End

Flowchart design of the problems

START

Set Fahrenheit

Celsius = (Fahrenheit - 32) * 5/9

Display the
temperature
in Celsius

End
Page 38, no2

i. The output for total


the total is 5

ii. The loop repeats.


- Loop repeat 5 times

iii. The output of total if count=count+1 is changed to count=count+3


the total is 6

iv. Flowchart using while loop

START

Total = 0
Count = 0

Count = count + 1

Total = total + count

False True
Count < 5

Print total

End
Page 42, no5

i. Pseudo code

1. Start
2. Set normal rate = 0.60
3. Set KWH above 1000
4. Set rate 0.45 for KWH above 1000
5. Calculate total electric bill using the formula:
under 1000 KWH = KWH * 0.60
above 1000 KWH = KWH * 0.45
6. Display the total electric bill in RM
7. End

ii. The cost for;


a. 900KWH
under 1000 KWH
900 KWH * 0.60 = RM540.00

b. 1754 KWH
above 1000 KWH
1754 KWH * 0.45 = RM789.30

c. 10000 KWH
above 1000 KWH
10000 KWH * 0.45 = RM4500.00

You might also like