ACTIVITY 3B: Fundamentals of Programming Language: Learning Outcomes
ACTIVITY 3B: Fundamentals of Programming Language: Learning Outcomes
Duration: 2 Hours
Learning Outcomes
This lab activity encompasses activities 3B.1, 3B.2, 3B.3, 3B.4 and 3B.5
CASE STUDY
Infinity Design Solution Sdn. Bhd, an advertising company wants to automate the system of managing Human
Resources (HR) data. Cik Suria was selected to be an IT programmer for Infinity Design Solution. En. Mohamed
insist to develop a system to manage staff payroll. Cik Suria has to prepare a proposal for payroll system.
INSTRUCTION:
Activity 3B.1
Activity Outcome: Solve problem using Assignment and Arithmetic operators.
Duration : 30 minutes
1. Find the value for the following expression. Show your steps of solution.
a. (1+2)+6*4/2–1 b. (6+4)/2–4
=(1+2)+24/2-1 =10/2-4
=(1+2)+12-1 = 5-4
=3+11 =1
=14
c. 6*3/6+9 d. 5 + 5 * ( 6 – 2)
=18/6+9 =5+5*4
=3+9 =5+20
=12 =25
=10+2 *7 -2 =10/2-(10*10+7)
=10+14-2 =10/2-(100+7)
=24-2 =10/2-(107)
=22 =5-(107)
= -102
c. (x * y) % z d. 5 (x + y + z) – x / z
=(10*7)%2 =5(10+7+2)-10/2
=(70)%2 =5*19 -10/2
=35 =95-5
=R 0 =90
e. xy – xz f. y (x + z) (x – y)
a. p + 3q - r b. p / r + ( p * p + r)
=6+3*2 -3 =6/3+(6*6+3)
=6+6-3 =6/3+(36+3)
=12-3 =6/3+39
=9 =2+39
=41
c. r ( p +q ) (p –q) d. 12/ p + ( p + q – r) – 6 / r
Activity 3B.2
Activity Outcome: Solve problem using Relational and Logical operators.
Duration : 30 minutes
=FALSE
ii. Fish && ( X > Y )
=FALSE
iii. ( X >= 0 ) && ( X <= Y )
(2>=0)&&(2<=Y) TRUE
=TRUE
iv. Fish && (! Fish)
=FALSE
v. ! Fish || ! (! Fish)
2. Given the value a = 0, b = 6 and c = 3. Write TRUE for the true expression and FALSE for the false
expression. Show all the steps clearly.
=TRUE
=( (0 == 3) && ( 6 == 3) ) || (0 < 1)
FALSE && FALSE || TRUEFALSE||
TRUE
TRUE
=TRUE
FALSE
=FALSE
Activity 3B.3
Activity Outcome: Write expression to solve problem by using appropriate operators.
Duration : 30 minutes
1. Given the value a = 4, b = 8. Find the answer by showing all the steps clearly.
TRUE || FALSE
= TRUE.
2. Given the following scenario. Identify the formula needed that combine operators to solve the
problems.
a. You want to buy 2 different types of magazines. Given the price of the magazine and the
number of magazines purchased, determine and print the total price to be paid.
Magazine 1-X
Magazine 2-Y
Total price-T
Number of magazine1-a
T=X*a + Y*b
b. I-City supermarket provides 15% discount from actual price. Find a solution to calculate the
new price after discount given.
Real price-X
Discount price-Y
0.15-Z
Y=X-(X*Z)
c. You are required to calculate total investment with dividends. Assume that the profit rate is
7.85% and the amount of your investment is RM15 000.
Total investment-a
0.0785-b
Amount Rm15000-c
A=c+(b*c)
Activity 3B.4
Activity Outcome: Write answer for increments and decrements operators.
Duration : 10 minutes
Determine whether the expression below is TRUE or FALSE and explain why you choose the answer.
ii. x = x-1;
TRUE
is the same as
It’s postfix decrement which is minus 1 after value of x
x--;
iii. int a = 5
TRUE
a++
It’s Postfix increment which is add 1 after value of a
answer = a is now 6
iv. int a = 5
int c TRUE
answer = c is now 6
v. int b = 7
TRUE.
++a
It’s postfix increment
answer = a is now 7
iv. int a = 10
FALSE.
a--
It’s prefix increment
answer = a is now 10
Answer=a is now 9
iiv. int a = 5
TRUE.
--a
BECAUSE IT IS PRE DECREMENT so A should
answer = a is now 4 beminus by 1 after a is assigned.
Activity 3B.5
Activity Outcome: System design (process expression/formula )
Duration : 20 minutes
PROBLEM
Case Senario:
The system will automate the process of calculate payroll for employees worked at Infinity Design Solution Sdn. Bhd.
Each employee will be recognized by employee ID. The system will receive gross income, allowance, overtime, income
tax and loan deduction. The system will automatically calculate the total income, total deduction and net salary for the
employee.