You are on page 1of 6

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

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

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

Define data type for each input, process, output


Case Scenario 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

You might also like