You are on page 1of 68

WORKBOOK ACTIVITY

1
Table of Contents
TOPICS PAGES

ACTIVITY 1: Introduction To Programming Language 3

ACTIVITY 2: Problem Solving 8

ACTIVITY 3: Programming Life Cycle 32

ACTIVITY 4: Types of Algorithm 58

2
ACTIVITY 1: Introduction of Programming Language
Duration: 2 Hours

Learning Outcomes
This lab activity encompasses activities 1.1, 1.2, 1.3, 1.4, 1.5 and 1.6

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


1. Differentiate the various categories of programming languages.
2. Explain the language translators.
3. Relate the programming languages application in real life.

CASE STUDY

Infinity Design Solution Sdn. Bhd, an advertising company wants to automate the system of
managing Human Resources (HR) data. The automation involves the staff details, staff payroll
and etc. En. Muhammed wants to hire an IT Programmer to develop a system. He draft a sets
of questions to test the general IT and programming knowledge of a new programmer.

INSTRUCTION:
1. You are one of the candidate for post IT Programmer, Infinity Design Solution Sdn. Bhd.
2. Answer the entire questions below.

Activity 1.1
Activity Outcome: Identify the programming language generation based on the figures given.
Duration : 10 minutes

Look carefully at the images given. The images uniquely represent each programming language
generation that you have learned. Can you identify and match the programming language
generation correctly?

Features

 A collection of binary numbers


understood by a computer.

Features

 Translation to machine language is


performed using compiler or interpreter.

Features

 Also known as symbolic language


because it uses mnemonic code.

3
Activity 1.2
Activity Outcome: Distinguish between the various language translators.
Duration : 20 minutes

Determine the language translator, X and Y in figure below and state TWO (2) of their
advantages and disadvantages.

X Y

Advantages

Disadvantages

Advantages

Disadvantages

4
Activity 1.3
Activity Outcome: Determine the lifecycle of a software project phases.
Duration : 20 minutes

Re arrange the phases in software project life cycle. Explain activities and task performs by
project team during each phase.

Design Testing Maintenance Build phase Requirements Deployment


phase phase phase gathering phase
phase

Phase Phase Name Activities and task


Level
1

Activity 1.4
Activity Outcome: Determine standards and best practices in writing program codes
Duration : 20 minutes

List standards and best practices in writing program codes

5
Activity 1.5
Activity Outcome: Determine programming languages application in real life.
Duration : 30 minutes

Discuss on steps needed to deposit cash on Cash Deposit Machine.

6
Activity 1.6
Activity Outcome: Determine programming languages application in real life.
Duration : 20 minutes

Discuss and list examples of suitable application which implements programming in real life
application in each field.

Medical
1. _________________________________

2. _________________________________

3. _________________________________

1. _________________________________

2. _________________________________

3. _________________________________

Education

on Agricultural
1. _________________________________

2. _________________________________

3. _________________________________

7
ACTIVITY 2A: Problem Solving Methods
Duration: 2 Hours

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

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


1. Demonstrate the understanding of Programming Life Cycle (PLC).
2. Relate the PLC with the life cycle of a Software Project.

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:
1. You have been assigned to help Cik Suria to prepare a proposal which include:
 Decide a proper title for the system
 Elaborate a system introduction
 State the problem statements
 Identify an objective
 Explain the phases in Programming Life Cycle (PLC) with examples.
a. Specify the problem
b. Analyze the problem
c. Design the algorithm to solve the problem
d. Implement the algorithm
e. Test and verify the completed program
f. Maintain and update the program
g. Documentation

• manage staff payroll


Case Scenario • (proposal)

Activity 2A.1
Activity Outcome: Decide a proper title for the system
Duration : 10 minutes

Title/ System name:

8
Activity 2A.2
Activity Outcome: Elaborate a system introduction
Duration : 20 minutes

System introduction:

Activity 2A.3
Activity Outcome: State the problem statements
Duration : 20 minutes

Problem statements:

1.

2.

3.

Activity 2A.4
Activity Outcome: Identify an objective
Duration : 20 minutes

Objectives:

1.

2.

3.

9
Activity 2A.5
Activity Outcome: Explain the phases in Programming Life Cycle (PLC) with examples.
Duration : 25 minutes

Cik Suria asks you to prepare the planning for system development. You have to study the
phases and activities involves in program life cycle. Define the phase definition below to match
the Description with its appropriate Phase by using line in the space provided.

No Description No Phase
Run the program several times using different
1 sets of data Implementation

Process of modifying a software system or


component after delivery to correct faults,
2 improve performance or adapt to a Documentation
changed environment

Identify the input, process and output of the


3 problem Specify the problem

Determine the required form and units in


4 which the results should be displayed Design the algorithm

To build a code base on the algorithm being


Verification and
5 design
Testing
Develop a list of steps called an algorithm to
6 solve the problem Analyzing

A written or graphical report of the steps


Maintenance and
7 taken during the development of a program
update

10
• manage staff payroll
Case Scenario • (program life cycle)

Activity 2A.6
Activity Outcome: Relate the PLC with the life cycle of a Software Project.
Duration : 25 minutes

Based on scenario below, plan phase and activity that involved in Software Development
Method.

PAYROLL SYSTEM
1. Infinity Design Solution Sdn. Bhd. stores the data for employee payroll in file
system. The calculations for payroll are done manually by the clerk.
2. IT Department want to automate the process of payroll calculation by develop
a small application.
3. Programmer will save all data in the database and test whether the system can
calculate the payroll for the employees automatically.
4. Then, the new systems will be tested. The net salary for the employees will be
display and function well
5. All data in file system will transfer into computerized system for easy searching
and data updating.

No Phase Activities

1 Specify the problem

2 Analyzing

3 Design the algorithm

4 Implementation

5 Verification and Testing

6 Maintenance and update

7 Documentation

11
ACTIVITY 2B: Problem Solving Methods
Duration: 2 Hours

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

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


1. Identify the input, process and output based on problem statement.
2. Illustrate the problem solving concept using IPO chart based on the problem statement.
3. Identify various tools used in problem solving.

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:
1. You have been assigned to help Cik Suria to prepare a proposal which include:
 System analysis (define input, process and output)
 Create a complete IPO chart

Activity 2B.1
Activity Outcome: System analysis (define input, process and output )
Duration : 20 minutes

You try to find out some exercises to identify input, process and output from real life application
as below:

Problem 1:

Below is the set of work flows of Auto Pay Machine for Parking Ticket. Select the appropriate
instruction to be place in the correct box by categorizing them into input, process and output
instructions. Highlight / underline your answer.

Set of Instructions:
1) Insert parking ticket ( input / process / output )
2) The payment will be calculated based on the duration ( input / process / output )
3) Parking fee will be displayed ( input / process / output )
4) Pay by notes or coins ( input / process / output )
5) Calculate the change for payment balance ( input / process / output )
6) Processed parking ticket ( input / process / output )
7) Verify amount of money inserted ( input / process / output )

12
Problem 2:

Below is the set of work flows of Course Registration for student. Select the appropriate instruction
to be place in the correct box by categorizing them into input, process and output instructions.
Highlight / underline your answer.

Set of Instructions:

1) Save selected class for course registration in the database ( input / process / output )
2) Course registration slip display at the screen ( input / process / output )
3) Select course for registration ( input / process / output )
4) Printed course registration slip ( input / process / output )
5) Enter your ID and password ( input / process / output )
6) System will validate your ID and password ( input / process / output )
7) Select the class that offer the course selected before ( input / process / output )
8) Save selected course registration in the database ( input / process / output )

Activity 2B.2
Activity Outcome: System analysis (Identify input, process and output)
Duration : 45 minutes

You do some research on defining input, process and output for certain problem as examples
below:

Problem 1: Input: 3 numbers


Calculate total of three Process : Calculate total of three numbers by add all 3 numbers
numbers Output : total of three numbers
Problem 2: Input: birth year, current year
Calculate age Process : Calculate age by current year deduct birth year
Output : age

You try some exercise to get more understanding about defining input, process and output as
below:

Problem 1: Input:
To buy the books from the book shop,
cashier will scan the price of the books and
quantity of the book. Then the system will
calculate the total price of the books. Process :

Output :

13
Problem 2: Input:
Aiman wants to know his BMI. His weight is
calculated in kilogram and height is
calculated in meter. Help Aiman to find his Process :
BMI.

Output :

Problem 3: Input:
To rent a video, customer need to scan the
video serial number at our shop scanner
and the details of the video will be save in Process :
the system automatically. Next, the scanner
will print out the details about the video
rental. Lastly, the customer needs to go to
counter and pay for the rental fee. Output :

Problem 4: Input:
Every employee needs to thumb their
fingerprint everyday as proof of their daily
attendance to the work. Then the Process :
attendance system will save the employee
information such as name, time and date.
The information can be printed out at the
end of the month. Output :

Problem 5: Input:
Create a receipt for a list of five (5)
purchased items. Print the total price,
compute the total with 8.25% tax and print Process :
the money tendered (plus any change
given).

Output :

Problem 6: Input:
You have been hired by Prima Hotel as a
programmer. Your task is to develop a
program that can count the total rate by Process :
multiply room rate with number of days,
and add 10% room service charges. Draw
the flowchart by using the problem analysis
below.

Output :

14
Problem 7: Input:
Mr Wong is a mathematics teacher. He
wants to teach his students about how to
convert time in hour into the times in Process :
minute. Help Mr Wong to solve his problem.

Output :

• manage staff payroll


Case Scenario • (define input, process, output)

Activity 2B.3
Activity Outcome: System analysis (Identify input, process and output )
Duration : 15 minutes

Define input, process and output for module manage staff payroll.

Case Senario: Input:


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 basic salary, Process :
allowance, overtime, income tax and loan
deduction. The system will automatically
calculate the gross salary, total deduction
and net salary for the employee.

Output :

15
Activity 2B.4
Activity Outcome: create a complete IPO chart
Duration : 25 minutes

Cik Suria wants you to summarize your input, process and output into IPO chart. You do some
research on IPO chart as examples below:

Problem 1: Input: 3 numbers


Calculate total of three Process : Calculate total of three numbers by add all 3 numbers
numbers Output : total of three numbers

IPO chart:

Input Process Output


3 numbers Add all 3 numbers Total

Problem 2: Input: birth year, current year


Calculate age Process : Calculate age by current year deduct birth year
Output : age

IPO chart :

Input Process Output


birth year, current year current year – birth year age

You try some exercise to get more understanding about IPO chart as below:

PROBLEM IPO CHART


Problem 1:
To buy the books from the book
shop, cashier will scan the price of
the books and quantity of the
book. Then the system will
calculate the total price of the
books.

Problem 2:
Aiman wants to know his BMI. His
weight is calculated in kilogram
and height is calculated in meter.
Help Aiman to find his BMI.

16
Problem 3:
Mr Wong is a mathematics
teacher. He wants to teach his
students about how to convert
time in hour into the times in
minute. Help Mr Wong to solve his
problem.

• manage staff payroll


Case Scenario • (IPO chart)

Activity 2B.5
Activity Outcome: create a complete IPO chart
Duration : 15 minutes

Define IPO chart for module manage staff payroll.

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 basic salary, allowance, overtime, income tax and loan
deduction. The system will automatically calculate the gross salary, total deduction
and net salary for the employee.

IPO chart :

Input Process Output

17
ACTIVITY 2C: Problem Solving Methods
Duration: 2 Hours

Learning Outcomes
This lab activity encompasses activities 2C.1, 2C.2 and 2C.3

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


1. Write an algorithm.
2. Identify the various types of algorithm (Pseudo code).

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:
1. You have been assigned to help Cik Suria to prepare a proposal which include:
 System design (algorithm and pseudo code )

Activity 2C.1
Activity Outcome: System design (algorithm and pseudo code )
Duration : 50 minutes

Cik Suria ask you to proceed with system design. You have to write an algorithm for problem
analysis created before. You do some research on algorithm as examples below:

PROBLEM PROBLEM ANALYSIS PROBLEM DESIGN (ALGORITHM)


Problem 1: Input: 3 numbers 1. Enter 3 numbers
Calculate total of three Process : Calculate total 2. Calculate total of three numbers
numbers of three numbers by add 3. Display total of three numbers
all 3 numbers
Output : total of three
numbers
Problem 2: Input: birth year, current 1. Enter birth year, current year
Calculate age year 2. Calculate age
Process : Calculate age 2.1 (current year – birth year) as age
by current year deduct 3. Display age
birth year
Output : age

18
You try some exercise to get more understanding about algorithm as below:

PROBLEM ALGORITHM
Problem 1:
To buy the books from the book shop,
cashier will scan the price of the books and
quantity of the book. Then the system will
calculate the total price of the books.

Problem 2:
Aiman wants to know his BMI. His weight is
calculated in kilogram and height is
calculated in meter. Help Aiman to find his
BMI.

Problem 3:
To rent a video, customer need to scan the
video serial number at our shop scanner
and the details of the video will be save in
the system automatically. Next, the scanner
will print out the details about the video
rental. Lastly, the customer needs to go to
counter and pay for the rental fee.
Problem 4:
Every employee needs to thumb their
fingerprint everyday as proof of their daily
attendance to the work. Then the
attendance system will save the employee
information such as name, time and date.
The information can be printed out at the
end of the month.
Problem 5:
Create a receipt for a list of five (5)
purchased items. Print the total price,
compute the total with 8.25% tax and print
the money tendered (plus any change
given).

Problem 6:
You have been hired by Prima Hotel as a
programmer. Your task is to develop a
program that can count the total rate by
multiply room rate with number of days,
and add 10% room service charges. Draw
the flowchart by using the problem analysis
below.

19
Problem 7:
Mr Wong is a mathematics teacher. He
wants to teach his students about how to
convert time in hour into the times in
minute. Help Mr Wong to solve his problem.

Problem 8:
You have been hired by Prima Hotel as a
programmer. Your task is to develop a
program that can count the total rate by
multiply room rate with number of days,
and add 10% room service charges. Draw
the flowchart by using the problem analysis
below.

Activity 2C.2
Activity Outcome: System design (algorithm and pseudocode )
Duration : 50 minutes

After study about algorithm, Cik Suria wants you to you do some research on writing pseudo
code.
PROBLEM PROBLEM ANALYSIS PROBLEM DESIGN (PSEUDO CODE)
Problem 1: Input: 3 numbers Start
Calculate total of three Process : Calculate total Enter 3 number (num1, num2, num3)
numbers of three numbers by add Calculate total of three numbers
all 3 numbers Total of three numbers = num1 +
Output : total of three num2 + num3
numbers Display total of three numbers
End
Problem 2: Input: birth year, current Start
Calculate age year Enter birth year, current year
Process : Calculate age Calculate age
by current year deduct age = current year – birth year
birth year Display age
Output : age End

You try some exercise to get more understanding about pseudo code as below:

PROBLEM PSEUDO CODE


Problem 1:
To buy the books from the book shop,
cashier will scan the price of the books and
quantity of the book. Then the system will
calculate the total price of the books.

20
Problem 2:
Aiman wants to know his BMI. His weight is
calculated in kilogram and height is
calculated in meter. Help Aiman to find his
BMI.

Problem 3:
To rent a video, customer need to scan the
video serial number at our shop scanner
and the details of the video will be save in
the system automatically. Next, the scanner
will print out the details about the video
rental. Lastly, the customer needs to go to
counter and pay for the rental fee.

Problem 4:
Every employee needs to thumb their
fingerprint everyday as proof of their daily
attendance to the work. Then the
attendance system will save the employee
information such as name, time and date.
The information can be printed out at the
end of the month.

Problem 5:
Create a receipt for a list of five (5)
purchased items. Print the total price,
compute the total with 8.25% tax and print
the money tendered (plus any change
given).

Problem 6:
You have been hired by Prima Hotel as a
programmer. Your task is to develop a
program that can count the total rate by
multiply room rate with number of days,
and add 10% room service charges. Draw
the flowchart by using the problem analysis
below.

21
Problem 7:
Mr Wong is a mathematics teacher. He
wants to teach his students about how to
convert time in hour into the times in
minute. Help Mr Wong to solve his problem.

Problem 8:
You have been hired by Prima Hotel as a
programmer. Your task is to develop a
program that can count the total rate by
multiply room rate with number of days,
and add 10% room service charges. Draw
the flowchart by using the problem analysis
below.

• manage staff payroll


Case Scenario • (define input, process, output)

Activity 2C.3
Activity Outcome: System design (algorithm and pseudocode )
Duration : 20 minutes

Define algorithm and pseudo code for module manage staff 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.

ALGORITHM PSEUDO CODE

22
ACTIVITY 2D: Problem Solving Methods
Duration: 2 Hours

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

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


1. Identify the various types of algorithm (Flow chart).
2. Develop flowchart using problem solving tools (Raptor).

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:
1. You have been assigned to help Cik Suria to prepare a proposal which include:
 System design (flow chart )

Activity 2D.1
Activity Outcome: System design (flow chart )
Duration : 30 minutes

Cik Suria propose the algorithm and pseudo En. Muhammed. En. Muhammed wants to convert
the algorithm or pseudo code into flow chart. Cik Suria ask you to proceed with system design
and try to convert algorithm and pseudo code into flow chart. You do some research on flow
chart as examples below:

PROBLEM DESIGN
PROBLEM PROBLEM DESIGN (FLOW CHART)
(ALGORITHM)
Problem 1: 1. Enter 3 numbers
Calculate total 2. Calculate total of three Start
of three numbers
numbers 3. Display total of three
numbers num1, num2, num3

total = num1 + num2 + num3

display total

End

23
Problem 2: 1. Enter birth year, current
Calculate age year
Start
2. Calculate age
2.1 (current year – birth
year) as age birth year, current year
3. Display age

age = current year – birth year

display age

End

You try some exercise to get more understanding about algorithm as below:

PROBLEM FLOW CHART


Problem 1:
To buy the books from the book shop,
cashier will scan the price of the books and
quantity of the book. Then the system will
calculate the total price of the books.

Problem 2:
Aiman wants to know his BMI. His weight is
calculated in kilogram and height is
calculated in meter. Help Aiman to find his
BMI.

24
Problem 3:
To rent a video, customer need to scan the
video serial number at our shop scanner
and the details of the video will be save in
the system automatically. Next, the scanner
will print out the details about the video
rental. Lastly, the customer needs to go to
counter and pay for the rental fee.

Problem 4:
Every employee needs to thumb their
fingerprint everyday as proof of their daily
attendance to the work. Then the
attendance system will save the employee
information such as name, time and date.
The information can be printed out at the
end of the month.

25
Problem 5:
Create a receipt for a list of five (5)
purchased items. Print the total price,
compute the total with 8.25% tax and print
the money tendered (plus any change
given).

Problem 6:
You have been hired by Prima Hotel as a
programmer. Your task is to develop a
program that can count the total rate by
multiply room rate with number of days,
and add 10% room service charges. Draw
the flowchart by using the problem analysis
below.

26
Problem 7:
Mr Wong is a mathematics teacher. He
wants to teach his students about how to
convert time in hour into the times in
minute. Help Mr Wong to solve his problem
by construct a flowchart.

Problem 8:
You have been hired by Prima Hotel as a
programmer. Your task is to develop a
program that can count the total rate by
multiply room rate with number of days,
and add 10% room service charges. Draw
the flowchart by using the problem analysis
below.

27
Activity 2D.2
Activity Outcome: System design (algorithm, pseudo code and flow chart )
Duration : 30 minutes

After study about algorithm, Cik Suria wants you to you do some exercise on converting
between algorithm, pseudo code and flow chart.

ALGORITHM FLOW CHART

1) Input gross_income, cost, allowance,


overtime
2) Calculate net income using formula:
net_income = (gross_income –
cost) + allowance + overtime
3) Display net_income

1) Input meter
2) Convert meter to kilometer
2.1) kilometer = meter * 1000
3) Display kilometer

28
FLOW CHART PSEUDO CODE

START
Set Total = 0, Average = 0;
Input quiz1, quiz2, quiz3;
Calculate Total
Total = quiz1 + quiz2 + quiz3;
Calculate Average
Average = Total / 3;
Display Average;
END

START

Set total sale = 0

Input
item_price

discount_price = item_price * 25%

new_price =item_price – discount_price

Print discount_price and


new_price

END

29
• manage staff payroll
Case Scenario • (define input, process, output)

Activity 2D.3
Activity Outcome: System design (flow chart )
Duration : 15 minutes

Draw flow chart for module manage staff 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.

FLOW CHART

30
Activity 2D.4
Activity Outcome: Develop flowchart using problem solving tools (Raptor).
Duration : 45 minutes

Cik Suria just realizes that instead of using Microsoft Word to develop flow chart, you can use
Raptor tools to develop flow chart more easily. You do some research on Raptor tools and try to
develop all flow chart in Lab 2D.1, 2D.2 and 2D.3 by using Raptor tools.

31
ACTIVITY 3A: Fundamentals of Programming Language
Duration: 2 Hours

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

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


1. Define Identifier, variable, constant and reserved word.
2. Apply the correct naming conventions.

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:
1. Define the appropriate data type for each input, process and output.
2. Define proper correct naming convention for identifier.

Activity 3A.1
Activity Outcome: Identify the data type for the expression below.
Duration : 20 minutes

Based on expression below, you are required to determine the data type for each expression
below:

No Expression Data Type

1 Number123

2 2016

3 -0.000000001

4 0.741

5 X

6 $

7 173.00

8 ()

9 grade

10 123456

32
Activity 3A.2
Activity Outcome: Identify the variables and data type based on the problems.
Duration : 25 minutes

Based on the problem given, writes the suitable variable and data type.

1. Calculate area of a circle using a given radius.


Variable Data type

2. Age can be calculated based on the birth year and the current year. State the suitable
variable and the data type to complete the calculation.

Variable Data type

3. You are creating a simple program to identify if a student passed or fail for their marks in the
mid semester test. State the suitable variable and data type to complete the program.

Variable Data type

4. A shopping mall is currently having a sale for the coming festive season. All groceries item will
be given 20% discount and all clothing item will be given 15% discount. State the suitable
variable and the correct data type to calculate the discounted price for all items bought in
the shopping mall.

Variable Data type

33
5. A simple program is created to store personal data of an employee. The information that
needs to be store includes full name, phone number and employee number. State the
suitable variable and data type to complete the program.

Variable Data type

Activity 3A.3
Activity Outcome: Understand identifier, variable, constant and reserved words.
Duration : 20 minutes

1. Give the meaning of variable and constant and briefly explain the different between
variable and constant?

Variable Constant

2. Based on the table below, answer TRUE or FALSE.

NO RESERVED WORD TRUE/FALSE

1 break
2 number

3 return
4 braces

5 void
6 while

7 word
8 if

9 continue
10 int

34
3. Explain the function of the following terms and include 1 example of usage in C++
programming.

Terms Function Example

const

true

and

return

Activity 3A.4
Activity Outcome: Understand how to write the correct rules of naming identifier.
Duration : 25 minutes

1. Which of the following variables, identify valid or invalid? If invalid, give the reason.

NO RESERVED WORD VALID / INVALID REASON

1 Age

2 !ex

3 R79J

4 TotalIncome

5 _invalid

6 #validhashtag

7 100student

8 my_polytechnic

9 ILike Reading

10 num,ber1

35
2. State “TRUE” or “FALSE” for each of the variables declaration below.

NO VARIABLE DECLARATIONS TRUE / FALSE

int class;
1

float price$;
2

int &studentName;
3

char %discountRate;
4

int Student IC;


5

int _ICnumber;
6

char 4saleItem;
7

int register;
8

char switch;
9

int enum;
10

36
• Define data type for each input, process,
Case Scenario output
• Correct naming conventions for identifier.

Activity 3A.5
Activity Outcome: System design (variable and data type )
Duration : 30 minutes

Define the correct variable and data type for module manage staff 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.

VARIABLE DATA TYPE

37
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

c. 6 * 3 / 6 + 9 d. 5 + 5 * ( 6 – 2)

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

c. (x * y) % z d. 5 (x + y + z) – x / z

e. xy – xz f. y (x + z) (x – y)

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)

c. r ( p +q ) (p –q) d. 12/ p + ( p + q – r) – 6 / r

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

ii. Fish && ( X > Y )

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

iv. Fish && (! Fish)

v. ! Fish || ! (! Fish)

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

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

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

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

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

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

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

b. I-City supermarket provides 15% discount from actual price. Find a solution to
calculate the new price after discount given.

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.

43
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;

is the same as

x++;

ii. x = x-1;

is the same as

x--;

iii. int a = 5

a++

answer = a is now 6

iv. int a = 5
int c

c = a++

answer = c is now 6

v. int b = 7

++a

answer = a is now 7

iv. int a = 10

a--

answer = a is now 10

iiv. int a = 5

--a

answer = a is now 4

44
• Write the correct expression in a program
Case Scenario by 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)

45
ACTIVITY 3C: Fundamentals of Programming Language
Duration: 2 Hours

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

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


1. Apply control structure into pseudocode and flow chart.
2. Choose the appropriate control structure to design system.

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:
3. Illustrate the flow of control structure using pseudocode and flow chart in design
system.

Activity 3C.1
Activity Outcome: Write pseudo code and flowchart for selection control structure in solving
given problems.
Duration : 30 minutes

Based on the problems given, write the pseudo code and flowchart for selection control
structure.

1. Program that receives the current temperature as input. If the temperature is 80 degrees
or more, output a message telling the user to go swimming, otherwise, if the temperature
is 50 degrees or more, output a message to go running, otherwise stay inside.

a. Pseudo Code

46
b. Flowchart

47
2. Jusco Supermarket is now offering some discount on selected items for Carnival Mega
sale. Help the supermarket cashiers to calculate the net price of the selected product’s
below.

Position Discount
1. Food Item 5%
2. Health Item 6%
3. Electric Item 9%
4. Cloth Item 4%

a. Pseudo code

48
b. Write a Flowchart

49
Activity 3C.2
Activity Outcome: Write pseudo code and flowchart using repetition control structures in solving
given problems.
Duration : 30 minutes

1. Based on the algorithm below, prepare a pseudo code and flowchart for each type of
repetition control structures.

1. Initialize Counter = 1; average = 0; Total = 0;


2. Input number.
3. Add Total using formula:
Total = Total + number
4. Add Counter using formula:
Counter = Counter + 1
5. Compare whether Counter is greater than 5.
If yes, go to step 6.
If no, go to step 2.
6. Calculate Average of numbers using formula:
Average = Total / 5
7. Display Average.

a. Pseudo code:

For Loop

50
While Loop

Do..While Loop

51
b. Flowchart:

For Loop While Loop Do..While Loop

52
2. A class of ten students took a quiz. The mark is between the ranges 0 - 25 for this quiz is
available to you. Determine the average mark for this quiz. Based on this problem, you
are required to:

a) Identify the input, process and output for this problem.

Input

Process

Output

b) Write a pseudo code and flowchart to solve the problem given.

Pseudo code:

53
Flowchart:

54
Activity 3C.3
Activity Outcome: Design the pseudocode and flowchart for a given case study using problem
solving tools.
Duration : 30 minutes

1. A car park has the following charges. The 1st hours cost RM2.00. The sub sequent hours
cost RM1.00 per hour. Design the algorithm for this problem and draw flowchart using
problem solving tools.

55
2. Calculate the salary that employee get based on number of working. Rate of the
payment is RM8.00 per hour but the salary will be deducted with 10% KWSP. By using a
repetition control structure, write pseudo code and design a flowchart using problem
solving tools to calculate the total salary of 5 employees and the average salary of the
employee.

56
• illustrate flow of control structure in a
Case Scenario program.

Activity 3C.4
Activity Outcome: System design (write pseudocode and darw flowchart)
Duration : 30 minutes

Illustrare the flow of control structure using pseudocode and floechart.

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.

Pseudocode Flowchart

57
ACTIVITY 4A: Basic Programming Codes
Duration: 2 Hours

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

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


1. Identify basic elements of the programming language.
2. Identify input, process and output from the given codes.
3. Construct pseudo code and flowchart based on given programming code.

CASE STUDY

Infinity Design Solution Sdn. Bhd, has received your application as an industrial student to run
your practical in this company for three months. Miss Suria whom is the IT programmer for
Infinity Design Solution is pointed to be your supervisor. As you are new in working environment;
Miss Suria plan to brief you on the programming language elements before major tasks are
appointed to you.

INSTRUCTION:
Your task is to convince Miss Suria that you are familiar with the programming language
elements by filling up all the boxes:

Diagram 1

58
• Identify basic elements of programming
Case Scenario language

Activity 4A.1
Activity Outcome: Programming Language Elements
Duration : 1 hour

Your task is to convince Miss Suria that you are familiar with the programming language
elements by filling up all the boxes:

PROBLEM SOLUTION
Problem 1:
A
Based on the case study programming
B
language, identify the elements noted in A-G
C
D
E
F
G

Problem 2:
You are required to identify the basic
elements of the programming code below: a. Comment :

// Program to display the message


// Welcome to a new language b. Preprocessor directive :
#include <iostream>
using namespace std; c. Main function :

int main()
d. Reserved word :
{
cout << " Welcome to C++
Programming Language! "; e. Special symbol :

return 0;
} f. Punctuation :

g. Statements :

59
Problem 3:
Program Input:
You need to identify and write out the
program input, process and output. Please
refer to Diagram 1 to answer this question. Process:

Program Output:

60
• Define program code
Case Scenario • Construct flowchart

Activity 4A.2
Activity Outcome: Constructing Flowchart
Duration : 30 minutes

Miss Suria has provided you with extra tasks to perform a flowchart based on the codes given :

GIVEN CODE CONVERT TO FLOW CHART

// AddTwoNumbers

// Computes the sum of two numbers

inputed at the keyboard.

#include <iostream>

using namespace std;

int main()

int a, b, total ;

cout << "Input numbers to be

added: " << endl;

cin >> a >> b ;

total = a + b ;

cout << "The sum is " << total

<< endl;

return 0;

61
}

• Define program code


Case Scenario • Construct pseudocode

Activity 4A.3
Activity Outcome: Constructing Pseudocode
Duration : 30 minutes

Miss Suria has added you with another tasks to perform pseudocode based on the codes given :

GIVEN CODE CONVERT TO PSEUDOCODE

// AddTwoNumbers

// Computes the sum of two numbers

inputed at the keyboard.

#include <iostream>

using namespace std;

int main()

int a, b, total ;

cout << "Input numbers to be

added: " << endl;

cin >> a >> b ;

total = a + b ;

62
cout << "The sum is " << total

<< endl;

return 0;

ACTIVITY 4B: Basic Programming Codes


Duration: 2 Hours

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

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


1. Declare variables/ constant used in problems given.
2. Write a basic program codes based on problem given.
3. Construct pseudo code and flowchart based on given programming code.

CASE STUDY

Congratulations to you!!

You have impressed Miss Suria on your capability to solve the task handed to you in 4A.
Therefore, Infinity Design Solution Sdn. Bhd, with the supervision of Miss Suria has given you the
task to help Finance Unit in completing payroll system. The scenario is that; Infinity Design
Solution announces that it wants to increase employees salary by 13% from gross pay and 5 %
from allowance received.

Instruction: Follow the process below in completing your codes.

63
Case Scenario • Identify input, process, output

Activity 4B.1
Activity Outcome: Identify input, process and output
Duration : 30 minutes

Task 1: You must identify the input, process and output from the given task

INPUT PROCESS OUTPUT

64
Case Scenario • Construct Flowchart

Activity 4B.2
Activity Outcome: Constructing Flowchart
Duration : 30 minutes

Task 1: Construct a flowchart of the given task based on 4B.1

Flowchart

65
Case Scenario • Construct Pseudocode

Activity 4B.3
Activity Outcome: Constructing Pseudocode
Duration : 30 minutes

Task 1: Construct a pseudocode of the given task based on 4B.2

Pseudocode

66
Case Scenario • Write Program Code

Activity 4B.4
Activity Outcome: Write program code
Duration : 30 minutes

Task 1: Write a complete code of the given task based on 4B.3

Program Code

67
68

You might also like