You are on page 1of 5

UNTVERSITI

ETRONAS

FINAL EXAMINATION
SEPTEMBER 2013 SEMESTER
COURSE :

TCB1013/T881073/TC82073 STRUCTURED
PROGRAMMING / STRUCTURED PROGRAMMING

AND DATABASE

DATE :
TIME :

22"d DECEMBER 2O1g (SUNDAY)

9:00 AM

- 12:00 NOON (3 HOURS)

INSTRUCTIONS TO CANDIDATES

1.

SECTION A - Answer ALL questions in this section on the OMR sheet given.
SECTION B - Answer ALL questions in this section on the Answer Booklet given.

2.
3.
4.

Begn EACH answer on a new page in the Answer booklet given.

lndicate clearly answers that are cancelled, if any.


Where applicable, show clearly steps taken in arriving at the solutions and indicate

ALL assumptions.

5.

Do not open this Question Booklet until instructed.

Note

There are SEVENTEEN (f 7) pages in this Question Booklet including the


cover page.

Universiti

Teknologi

PETRONAS

TCB

SECTION B

3/TB

B 1 07

3fi

CB.207 3

Subjective Questions (60 Marks)

There are THREE (3) questions in this section. Answer all questions in the answer
booklet provided.

1.

a.

The price of a plane ticket is $1000 by default, but discounts are


applied to it basedon different criteria. The following rules determine
the discount, and hence the final price:

.
.

Students get 20% discount.


People who purchase 30 days n advance get20% discount.

Discount can aggregate, for example a student purchases3O days in


advance gets a 40% discount. The program wold ask the user for input

on whether the user is a student or not. Design a flowchart of your


algorithm that solves the following problem and calculates the final
pnce.

[10 marks]

b.

Generate

function named sum_from_tothat takes two integer

arguments, call them

first

and l-ast, and returns as its value the

sum of all the integers between first and last inclusive. Thus, for
example,

cout((sum from Lo(4,1) <<endf;


// will print 22 becauss {+$+$+7 = 22

cout((sum f rom to (-3, 1 ) ((endl

,'

// will print -5 'cause (-3)+(-2)+(-1)+0+1

-5

cout((sum from Lo(1 ,4) <<endl,'


// will print 22 because f +$+$+Q = 12

cout((sum from to(9,9) <<endl-;


// will print 9

[10 marks]

14

TCB
2

a.

0 1 3/TBB 1 07 3tT CB.207 3

State the output when the following code fragment is executed.


l -r

f 1l L

-. /

ll

float x: 3.8;
n: int(x);
cout<< 'rt - tr << n <<end1;

Translate the following flowchart to pseudo code.

[10 marks]

Dev

gram that will calcu ate the fo ow ng

Y-

ifx>0
+10 f x-0
ifx<0
15

TCB

3.

a.

Generate SQL commands

3/TBB

07 3tT CB.207 3

to create EMpLoyEE and DEpARTMENT

tables based on the table structure below.

EMPLOYEE (Emp_lDEmp_Name, Emp_Add,

Emp_phone,

Dept_Code)

DEPARTMENT (Dept_Code,Dept_Name, Dept_Loc)


[10 marks]

b.

construct sQL query to insert data into EMpr,oyEEtable using the


sample data below:

Employee
Name

ID

Phone

Department
Gode

Address

111667

03-27739001

MKT

No 5, Jalan
Permaisuri 3

[3 marks]

c.

The company you work for wants to digitize their time cards. You have
been asked to design the database for submitting and approving time
cards. Design the database ER diagram with the following information:

.
.
.
.
o
.
.
.
.

A timecard should have hours worked and date submitted


Each timecard is associated with exacily one employee
Each timecard should have a unique id

Each timecard has a status: it is either approved, not approved,


or pending
Each employee has a unique id

Each employee has a name and address.

Each employee submits a time card every pay period. i.e. ln


year, they will submit multiple time cards

Each employee either has direct deposit or physical check as


their method of payment
Each employee is associated with exacily one manager
16

TCB 1 01 3/TBB 1 07 3tT CB.207 3

o
o
.

Each manager has a unique id and a name


Each manager is in charge of multiple employees
Each manager approves time cards for multiple employees
[7 marks]

- END OF PAPER 17

You might also like