The words you are searching are inside this book. To get more targeted content, please make full-text search by clicking here.

Related Publications

Discover the best professional documents and content resources in AnyFlip Document Base.

Keywords: algorithm

WEEKEND HOMEWORK ASNWER:

QUESTION1

IPO Analysis
INPUT: number
PROSES: To determine whether the number is divisible by 2 or not.
OUPUT: message “ even number” or “odd number”

Start
if number %2 == 0
Print “even number”
Else
Print “odd number”
Stop

QUESTION 2:
INPUT: membership, purchase
PROSES: To determine membership and calculate total pay for the purchased item.
OUTPUT: total pay.

Start
If membership is yes.
Totalpay= purchase x 0.7
Else
Totalpay = purchase
End if
Print Totalpay
Stop

QUESTION 3
INPUT: hour
PROSES: to calculate parking charge based on hour
OUTPUT: parking charge
Start
If hour <=1
Parking charge = hour x RM1
Else
Parking charge = RM1 + (hour -1) x 0.5
End if
Print parking charge
Stop

QUESTION 4
INPUT: room type
PROSES: To determine room type and calculate room charge based on room type rates.
OUTPUT: room charge.

Start

If room type == Single
Room charge = 60

else if room type == Double
Room charge =100

else if room type == Triple
Room charge = 150

end if
end if
end if
Print Room charge
Stop

QUESTION 5
INPUT: number
PROSES to determine whether the number is positive, negative or zero.
OUTPUT:message “ Positive” or “ negative” or “ zero”

Start
If number <0

Print “negative”
else

if number >0
Print “ positive”
else
Print “zero”
End if
End if

Question 8
INPUT: distance
PROSES: To calculate payable sum based on distance.
OUTPUT: payable sum

Start
If distance <=500
Payable sum= 0.5 x distance
Else

If distance <=700
Payable sum = (500 x 0.5) + (distance – 500)* 0.4

Else
Payable sum = (500 x 0.5) + (200 x 0.4) + (distance – 700) * 0.3

QUESTION 9
INPUT: number of call.
PROSES: to determine number of call and calculate charge based on rates per call.
OUTPUT: charge

Start
Read number of call
If number of call <=100

Charge= 50
Else
If number of call <=200

Charge = 50 + (number of call-100) x 0.6
Else

Charge = 110+ (number of call – 200)*0.5
End if
Print Charge
stop