ALGORITHM AND PROGRAMMING (BIC 10204) (SECTION 4)
MADAM HANAYANTI BINTI HAFIT
a.) Find the mean of 4 numbers P,Q,R and S.
2. Draw the flow chart for the given questions .
MADAM HANAYANTI BINTI HAFIT
1. Identify what are the input, process
and output.
a.) Find the mean of 4 numbers P,Q,R and S.
Answer
Input :
P,Q,R,S
Process :
Calculate the mean = (P+Q+R+S)/4
Output : Mean
of 4 numbers
b.) Convert
a length of an object from millimeter to centimeter.
Answer
Input : Length
of object in millimeter
Process :
Convert millimeter to centimeter, length = 10/length in millimeter
Output :
Length of object in centimeter
c.) Calculate
the volume of a cone, if the volume is below 12cm³, print “Accepted” but if the
volume is equal or more than 12cm³, print “Not Accepted” .
Answer
Input : Volume of cone
Input : Volume of cone
Process :
Determine whether volume below, equal or more 12cm³
Output : Accepted, Not
Accepted
2. Draw the flow chart for the given questions .
a.) A
company selling sports goods would like to give a discounts to customers by
organizing an annual sales. If customers
buy goods of more than RM100 then customers will get a discount of 10%. However
if they buy RM500 and above then 50%
discount will be given.
Answer

b.)
A student
marking system receives input of student’s total mark from lecturer. If a
student gets total mark of 75 or above, the system will print ‘A’. if a
student’s mark is between 65 to 74, the system will print out ‘B’. while ‘C’
will be printed out if the mark is between 50 to 64. Whichever the total mark
is below 50, ‘F’ will be printed.
3. Write the
pseudocode / algorithm for the given questions.
a.) ABC
bank offers 5% discount if payment is made within 10 days after notice. No
discount if the payment is made after 10 days.
Answer
Start
Read
days,payment
If (days<=10)
net_payment
= payment – (0.05*payment)
else
net_payment
= payment
end if
Display
the net_payment
End
|
b.) A program
receives input of an integer number. This number is then to be multiplied by
numbers from 1 to 12. The result for each multiplication is printed.
Answer
Answer
Start
set
i=1 ;
while
i <=12
Read
number;
result
= number * i;
Display
the result
i
= i +1
End
|
Comments
Post a Comment