Sie sind auf Seite 1von 9

UNI1TI UNIVERSITI T'EKNOLOGI PE'TRONAS

IIT1ti
,.

COURSE

TBB1 73ITCB2O73 STRUCTURED PROGRAMMING AND DATABASE

DATE TIME

: :

1I SEPTEMBER 2011 (SUNDAY) 2.30 PM - 5.30 PM (3 HOURS)

INSTRUCTIONS T CANDIDATES 1. 2. 3. 4. Answer ALL questions from the Questions Booklet. Begin EACH answer on a new page in the Answer Booklet. Indicate clearly answers that are cancelled, if any. Where applicable, show clearly steps taken in arriving at the solutions and indicate ALL assumptions.

5.
Note

Do not open this Question Booklet until instructed.


There are NINE (9) pages in this Question Booklet including the cover

page.

I V(: yr3; i. t.:i Un::

'I'(: kr) L()cJi.

PErrxoNAs

TBB1073, TCB2073 -wa. Write a program that reds in three strings and them sorts

lexicographically. Enter three strings: Falzal Ahmad Fadzr! Ahrmad Fadzi! Faizal [5 Marks]

b.

Write a program that prompts the user to input the x_y coordinate of a pent in a Cartesian plane. The program shoutd then output a message the point is the origin, is located on the x- or (y-) axis, or indicating whether in a particular quadrant. For example: appears (0,0) istho origin (5,O) is on the x-axis (0, -12) is on the y-axis (-2,3) is in the second quadrant [10 Marks]

C.

to input a single letter. The program Write a program that prompts the user letter is a vowel or a consonant. The user then determine whether the will letter. The user might also input an invalid input either a small or big may letter or maybe enter more than I key which is other than the alphabetical if this happen. letter. Your program should give a warning [5 Marks]

TBBIO73, TCB2073

2.

a.

Write a program that estimates the temperature in a freezer (in Celsius) given the elapsed time, t(hours) since a power failure. Assume this temperature (T) is given by: T= (4t/t+2) +20
Where t is the time since the power failure. Your program should prompt the user to enter hew long it has been since the start of the failure in whole hours and minutes. Note that you will need to pass these two arguments into a function temperature named and convert the elapsed time into

hours. For example,

if the user enters 2 30 (2 hours 30 minutes), you

to convert this to would need

hours. The estimation temperature from .5 the function will be displayed in the main program.

Example. 1n ut Hour: 2 Minute: 30

Output Temperature (Celsius): 25.56

[1Q Marks]

T6B1073!. 1

C13201

b.

Given A and B as two integers input. Write a program which computes the difference between A and B by wing a function named sum num positive which then returns the positive difference to main program as the output. Input The first llne of the input contains an integer T which represents the test cases. In the following T lines, T test oases are given one number of line. Each test case consists of two integers A and B. per Output Your program should print #integers, one per line. The r i/i integer is the that your program has computed for the i4h test ease. answer TbQQuPutshctbe 2
45 I

ispayedexaqtIy

below: as

52 3 [70 Marks]

B81W
!

3, I

CB2V

73

3.

Manager at TOPRadio wants you to develop a program to recognize which radio have exceeded monthly listeners of more than 80 percent of their total channels broadcast channels.
a. Write a flow chart that show how the decision can be made from the following TABLkQI: selection] TABLE Q1 Allocation ICapacfty Average listeners _,,. ....__. . ...... ... _._ _ ..ERAFM _... . _. __...... _ ......_.__ - -... . _.. . _..,. _.. _. ..,... . .._ _ 3,000,000 ..... ,. _ . .. ...... _.... ... . ... 2,500,000 Radio
, .__2,000,000 ..... . _, . ._. _.. HOTFM

[lVote: you have to device suitable formula for the

3,000,000

.. _. _. . 2,000,000 . _M.. .... 4,000,000 . -- _._,__. ... ...... . _.. __. ....... _.... .,,.. _ W _. ...... _ KLFM MLFM 1200,000

3,000,000 4,000,000
3,500,000

...._, PPFM
ASFM -. m. SIIVARFM

2,800,000 2,000,000
. _....... _.. .., -- .. .. _.. _. _..,..... _ ,. 3,000,000

3,500,000

[5 marks] b. Write a complete C++ programming based on the followings: i. Dispay radios that are more than 70 percents of monthly listeners file named "Rado. as the input. txt" a and use [5 marks] ii. If the listeners are more than 80 percents, mark as popular. [5 marks]
iii. Display output to show the No I radio channels and the No 2 radio ohannols.

[5 marks]

TDIO1

3r

TC6L01

4.

a.

Give an example for each of following entity relationships:

I.

Manyto-One
[1 mark]

ii.

One-to-Ono [1 markJ mark]

iii.

Ono-toMany [1 mark] [1 mark]

Mv. Many4oMany
j1 mark]

b.

Give SQL statement which creates a Customers table consisting of the following fields:

Name

CHAR(30)

[1 mark]
ii. ID NUMBER(12)

11mark] iiL Address CHAR(50) [1 mark] iv. Telephone CHAR(11) [1 mark]

TBB IW
C. You are required to create a conceptual data model for AMR in First Eastern Spectrum project consultation. technologist certified dn. Bhd. that specializes

TC6L073

department

in Meter Reading comprise of

The department

has 40 consultants

handle up to 150 clients per year. Each and can the five types of IT on either one of

for consultation client can request

Each of the projects will be handled by a consultation team of four project. to five technologists. teams. consultation Each technologist is assigned to a maximum of four

i.

Identify the main entities possible to the department.

[4 marks] ii, Identify the main relationship type and specify the cardinality for each relationship.

[4 marks]
iii. Using your answers in part (c)(i) and part (c)(ii), draw a single Entity Relationship (ER) diagram to represent the data for the company. Use Chen Model notation. requirements

[4 marks]

TBBIO73, TCB2073

5.

a.

Correct the error of the code fragment in FIGURE Q5a.


float switch(x)
case case default: } :2. :6.

x;

cm
a: O: cout ccut ccut

H;
f'twer' "six"; "wrong "; number";

FIGURE Q5a [2 marks] Trace the output of the code fragment shown in FIGURE Q5b.

b.

FIGURE Q5b
[4 marks)

nWrite

the pattern as shown in FIGUREQ5(c), fragment that creates acode the height and the width. given

FIGURE 05c [6 marks] 8

TBBID73, TCB2073 d. Write a program that reds list of integer numbers from user one by one a

the user ends the list with a sentinel 9999. The program will display and the following information.

i.

The largest and lowest number

[2 marks] iL Indicate "Above average" it the average is more than 70 [3 marks]


iii. Indicate "Passed" if all of them are between 40 and 100 [3 marks]

OF PAPER-END

Das könnte Ihnen auch gefallen