100% found this document useful (1 vote)
557 views9 pages

ACTIVITY 3B: Fundamentals of Programming Language: Learning Outcomes

This document outlines an activity to teach programming fundamentals including operators. It includes 5 sections that teach: 1) using assignment, arithmetic, relational and logical operators to solve problems; 2) writing expressions using appropriate operators; 3) identifying formulas to solve word problems using operators; 4) understanding increment and decrement operators; and 5) solving problems in 30 minutes or less for each section. The goal is for students to learn to use different operators to develop programming solutions.

Uploaded by

Face Production
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
557 views9 pages

ACTIVITY 3B: Fundamentals of Programming Language: Learning Outcomes

This document outlines an activity to teach programming fundamentals including operators. It includes 5 sections that teach: 1) using assignment, arithmetic, relational and logical operators to solve problems; 2) writing expressions using appropriate operators; 3) identifying formulas to solve word problems using operators; 4) understanding increment and decrement operators; and 5) solving problems in 30 minutes or less for each section. The goal is for students to learn to use different operators to develop programming solutions.

Uploaded by

Face Production
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

ACTIVITY 3B: Fundamentals of Programming Language

Duration: 2 Hours

Learning Outcomes
This lab activity encompasses activities 3B.1, 3B.2, 3B.3, 3B.4 and 3B.5

By the end of this practical session, you should be able to:


Use following operators in a program :
 Assignment operators
 Arithmetic operators
 Relational operators
 Logical operator
 Increment and Decrement operators

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:

 Determine appropriate operators for use in the system.


 Write the correct expression with using suitable operator to archive the system’s objective.

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

2. Given integer variables x = 10, y = 7 and z = 2. Determine the value of each


of the arithmetic expression.
a. x + 2y – z b. x / z – (x * x + y)

=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)

=10*7-10*2 =7(10+2) (10-7)


=70-20 =70+14*(3)
=50 =84*3
=252

3. Given the following declaration and initial assignments p = 6, q = 2 and r =


3. Determine the value of each of the following assignments.

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

=3(6+2) (6-2) =12/6+(6+2-3)-6/3


=18+6 (6-2) =12/6+5-6/3
=24*4 =2+5-2
=96 =7-2
=5

Activity 3B.2
Activity Outcome: Solve problem using Relational and Logical operators.
Duration : 30 minutes

1. Determine whether the expression below is TRUE or FALSE if X = 2, Y = 6 and Fish =


FALSE. Show your steps of solution.
Expression TRUE / FALSE
i. ( X ==Y ) || ( Y <=3 )

(2==6) or (6<=3) FALSE


FALSE FALSE

=FALSE
ii. Fish && ( X > Y )

FALSE && (2>6)


FALSE
FALSE && FALSE

=FALSE
iii. ( X >= 0 ) && ( X <= Y )

(2>=0)&&(2<=Y) TRUE

TRUE && TRUE

=TRUE
iv. Fish && (! Fish)

FALSE && (NOT TRUE)

FALSE && TRUE FALSE

=FALSE

v. ! Fish || ! (! Fish)

NOT TRUE||NOT(NOT FALSE)


TRUE
TRUE || TRUE

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.

Expression TRUE / FALSE


i. ! ( a == 0) && (b != 2)
=! ( 0 == 0) && (6 != 2)
TRUE && TRUE

FALSE && TRUE TRUE

=TRUE

ii. ( (a == c) && ( b == c) ) || (a < 1)

=( (0 == 3) && ( 6 == 3) ) || (0 < 1)
FALSE && FALSE || TRUEFALSE||
TRUE
TRUE

=TRUE

iii. ! ( !( c !=4) || !(4 ==2) || !(a==0) )

! ( !( 3!=4) || !(4 ==2) || !(0==0) ) ! (!


TRUE) || !(FALSE) || !( TRUE )!
FALSE || TRUE || FALSE!(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.

a. answer = !(a==b) && (a>b)


answer = !(a==b) && (a>b)a. answer = !(4==8) && (4>8)= !(FALSE)
&&FALSETRUE&&FALSETRUEb.

answer = !(a==2) || (a<b)


= !(4==2) || (4<8)
!( FALSE)|| TRUE
TRUE || TRUE
TRUE

b. answer = !(a==2) || (a<b)

answer = !(a==2) || (a<b)


= !(4==2) || (4<8)
!( FALSE)|| TRUE
TRUE || TRUE
TRUE

c. answer = ((a + b > b) && (a == a)) || (b == a)

((4 + 8 > 8) && (4 == 4)) || (8 == 4)

TRUE && TRUE || FALSE

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

Number of magazine 2-b

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.

Expression TRUE / FALSE


i. x = x+1;
TRUE
is the same as
It’s Postfix increment which is add 1 after value of x
x++;

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

c = a++ It’s postfix increment, so value of a need add 1

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.

Write the correct expression in a program by


Case Scenario using appropriate operators.

Activity 3B.5
Activity Outcome: System design (process expression/formula )
Duration : 20 minutes

Write the correct expression with suitable operator to calculate payroll.

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.

Process Expression (formula)


A=income
B= income tax
C= loan deduction
1.input gross income, allowance, overtime, income
tax and loan deduction.

2.Calculate net salary (income, allowance, overtime,


D= allowance
income tax and loan deduction)
E= overtime
X=net salary
Display net salary
X=(A-B-C)+D+E

You might also like