Skip to main content

Lab Session 1 ( 17 September 2018)

ALGORITHM AND PROGRAMMING (BIC 10204) (SECTION 4)
MADAM HANAYANTI BINTI HAFIT

#teamsuccess

Lab session 1 (17 September 2018)


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
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.

     Answer




            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


     Start
         set i=1 ;
         while i <=12
                     Read number;
                     result = number * i;          
                     Display the result
         i = i +1
End
                      







Comments

Popular posts from this blog

Lab Session 3 ( 1 October 2018)

LAB ACTIVITY 3 QUESTION 1  a. )  ANSWER b. ) ANSWER  c.) ANSWER   QUESTION 2 2.1 Print a message to ask user to enter their name. 2.2 Read name. 2.3 Print a message to ask user to enter their height and weight in kg and m. 2.4 Read weight and height. 2.5 Print name. 2.6 Print weight and height. QUESTION 3 3.1 Declare identifier of integer data type named num1. 3.2 Declare identifier of float data type named num2. 3.3 Declare a constant called MAX with a value of 50.88. 3.4 Print a message to ask user to enter value for num1. 3.5 Read num1. 3.6 Print a message to ask user to enter value for num2. 3.7 Read num2. 3.8 Print a message to ask user to enter value for MAX. 3.9 Read MAX. 3.10 Print num1, num2 and MAX. ANSWER QUESTION 4 Develop a simple subject registration system. The program requires user to enter student's full name, I/C number, matric number, s...

Lab Session 7 ( 19 November 2018)

QUESTION A.) Create a program to generate a multiplication table by using while loop. The multiply is determined base on user input. QUESTION B.) Calculate the total of any five number using do... while loop. QUESTION C.) Write a program for the following problem by using for statement: Ahmad saves RM1000 in his account in a bank which returns 5% of annual interest. Assuming that all interests is left deposited in his account, calculate and print the amount of money in his account at the end of each year for 10 years by using for loop.