DATA PSUEDOCODE

Example of pseudocode / algorithm

calc avg of max for test1, test2, test3

1. begin
2. declaration of m1, m2, m3
3. ask user to enter m1, m2 and m3
4. (a) calc total -> m1, + m2 + m3
   (b) calc average by divide total uni 3
5. print average to the user
6. end

Question 1

Draw a pseudocode that will ask the user to type three integers and the statement will store into first, second and third variables. Then the program will add all the three numbers and print the sum of three numbers.

1. begin
2. declaration of num1, num2, num3
3. prompt user to enter num1, num2 and num3
4. calculate sum -> num1 + num2 + num3
5. print sum to user 
6. end

Question 2

Draw a pseudocode that will ask user to enter age and print ‘Too young to drive’ for user’s age less than or equal to 15, print ’Better clear the road’ for user’s age equal to 16, print ‘Good for driving’ for users age in the range 17 to 60, print ‘You are getting old for user’s age greater than 60. (age <= 15) (age == 16) (17 <= age <= 60) (age > 60)

1. begin
2. declaration of age
3. prompt user to enter age
4. if (age <= 15) then
       print "too young to drive"
       else if  (age == 16) then
           print "better clear the road"
           else if (17 <= age <= 60) then
               print "good for driving"
               else if (age > 60) then
                   print "you are getting old"
               end-if
           end-if 
       end-if
   end-if
5. end

Question 3

Write a program that prompts the user to input amount in Ringgit Malaysia. The program will display the new amount with tax. The calculation of tax based on the table below:

Amount (RM) Tax %
Less than 1000 8
1000 and above 12
1. begin
2. declaration of amount, amountWithTax
3. prompt for amount
4. if (amount < 1000) then
       set amountWithTax to (amount + (amount * 0.08))
   else
       set amountWithTax to (amount + (amount * 0.12))
   end-if
5. print amountWithTax on terminal
6. end

Question 4

You are required to write a pseudocode for a program to determine total marks of a subject, whereby the program will obtain data from the user including the course code, marks for quiz, test and final examination. Assume the total marks is 100%, given the contribution marks are 20%, 20% and 60% for quiz, test and final examination respectively. Your program will determine whether the student passes or fails. Given the passing mark is 60% and above.

1. begin
2. declaration of code, quiz, test, final, totalMarks
3. prompt for code, quiz, test, final
4. set totalMarks to (quiz * 0.2) + (test * 0.2) + (final * 0.6)
5. if (totalMarks >= 60) then
       print "pass"
   else
       print "fail"
   end-if
6. end