The words you are searching are inside this book. To get more targeted content, please make full-text search by clicking here.
Discover the best professional documents and content resources in AnyFlip Document Base.
Search
Published by inaazlin, 2018-12-11 19:24:24

Weekend Homework3 answer

Weekend Homework3 answer

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
read number
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
Read membership, purchase
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
Read hour
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
Read room type

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
Read number
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
Read distance
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


Click to View FlipBook Version