LAB 2 - BIC10204
QUESTION 1(a, b, and c):
1. Identify what are the input, process, and output.
a. Find the mean of 4 numbers, P, Q, R, and S.
b. Convert a length of an object from millimeter to centimeter.
c. Calculate the volume of a cone, if the volume is below 12cm^3, print “Accepted” but if the volume is equal or more than 12cm^3, print “Not Accepted”.
IPO FOR QUESTION 1(a, b, and c):
a.
- Input: P, Q, R, S
- Process: Mean = (P+Q+R+S)/4
- Output: Mean of 4 numbers
b.
- Input: Length of the object in millimeter
- Process: Unit conversion (mm to cm) = Length of the object in millimeter x 10
- Output: Length of the object in centimeter
c.
2. Draw the flowchart for the given questions.
a. A company selling sports goods would like to give discounts to customers by organizing
annual sales. If customers buy goods of more than RM 100 then customers will get a discount of 10%. However, if they buy RM 500 and above then a 50% discount will be given.
b. A student marking system receives input of a student’s total mark from the lecturer. If a student gets a 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.
FLOWCHARTS FOR QUESTION 2(a and b):
a.
b.
QUESTION 3(a and b):
3. Write the pseudocodes/algorithm for the given questions.
a. ABC bank offers a 5% discount if payment is made within 10 days after notice. No discount if the payment is made after 10 days.
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.
PSEUDOCODES FOR QUESTION 3(a and b):
a.
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.
START
SET i=1 ;
WHILE i <=12
READ number;
RESULT = number * i;
DISPLAY the Result
i = i +1
END
Written by Arif (AI210125)😁.
Comments
Post a Comment