Upload
kumutha
View
217
Download
1
Embed Size (px)
DESCRIPTION
Programming pass year [UTP]
Citation preview
U
ýNI. ýý ýS1TI ýni/iNYw'wi. výMlý'ýWUMwMFYMýw'ýn'nýXýAý. 'MYXYwýn; M
TE KNOLOG I ýIrMNwýY1NýNý'ýIwwýwýý.
1Y/ýIýMy7º,
u
PEI'ý' ý. ýý Nýý
MII
COURSE TB81073 STRUCTURED PROGRAMMING
AND DATABASE / TABIOI3 STRUCTURED
PROGRAMMING
DATE 24 NOVEMBER 2010 (WEDNESDAY)
TIME 2.30 PM - 5.30 PM (3 HOURS)
INSTRUCTIONS TO CANDIDATES
ý
A
Note
Answer ALL rMýuestlons from the Questions Booklet,
Begin EACH answer on a new page n the Answer Booklet�
lrýýýcate clearly answers that are cancelSýeci� ýf any. Where applicable, show clearly steps taken ýn arrvng at the solutions and
indicate ALL assumptions.
Do not open this Question Booklet until instructed.
Týýýýýýý are ýýýýýý (11) pages wýý this Question Book'et iýýýýýidäýg the
ýýýýr page
, i.
., I., t :. i 'r' ¬ý : k. "l"9 (): L ()g ý.. 1ý
ýýý1073/TAB 10 13
I. A senior manager at StoneWatcber wants to develop ý ýýýi&on support
system to have the ability to b'end petrol ingredients based on client's
request There are two types of clients' requests which are R0N95 and R0N97. To make product such as R0N95 two "ingredients must be blended
together as shown in TABLE QI . Only I 50 litres is used for each ingrethent to
be blended and each ingredient initial vafue is 2000 litres.
3. Draw flow chart to show the decision that can be made from TABLE
QI based on current stýýýý available n TABLE Q2 if the client request for R0N95.
TABLE QI
A+B A+BýC ýý. ý...... ýýýý.... ýýý. ýý. ý.. ý. ý. A+B+D ý. ýýý. ý.... ý. _ý. wA+D C+D B+D
ýý_
AAB+C ýýýýýýýýýýý
A+B+D ýý
'A+D C+CI B+D
ýýý. ý�ýý. ý.
RON ... ý., ý. ý. ý. ýý... ý.. ý, ý.. ý. ý R01195
. ý. ý.. wý.. W. w...,., ýý. ý. ý..
R0N97 R0N97 R0N95 R0N95 R0N95
TABLE Q2
[8 marks]
b. Write a complete C++ program based on the foilowings.
Dspýay quantities tor R0N95 that cart be produced based on current stock as ýn TABLE Q2 and use a text ýýe "RON. txt" as input and Print warning message it each ingredient in the stock is tess
than or equa' 30ý'% ý of initial values, and Display the output as shown ýý ýýýýýý Qt
2
Iýý ý 073/TAB °i 013
tu*Pent stock
ýS$I BON9S
ýý ýýýýý it ýýýs for A +ý are 4 Un its ýB is critical »195 Quarýýýýýýý for ýýD are 3 Units
2. S ýD is critical ýýýý ýýýýý it ýýý ýýý ýýý are 3 Urý its 0N95 Quant it ics for B*ý are 3 tIn its
any ýýýý to ýýýýýýnue
FIGURE QI
[12 marks]
Týýý073iTA8 1013
ý. a in a robotic competition, you are required to determine the speed of a robot movement based on the colour of the controHer buttons as f'h/'flowsw
ý
Green increase the current speed by 2
ýýýýýý - decrease the current speed by 2 if the current speed is
not zero Red - stop the robot
i. ýýýý a complete flowchart to solve the prob'em.
ii. Write a C++ coce using if.. M else statement.
wiii Rewrite ý ýý+ code in part (ii) using switch statement.
[5 masks]
[5 marks]
[5 marks]
b. Trace and write the output for the C++ program n FIGURE Q2. Show
all the hand trace steps.
4
TBB 1 073/TAB 1 013
ý #include <icý strearn>
using naýillýý . pacE' std;
i. nt : ma in t' :ýý
ý: ýý t start ,ý end .,,, . 3;
. ýt iýýopVar1. ý lýýopvar2 � lýýýýýva r3;
char space -- " 4ý ýr
fcar ( iýýýýýýýýýýri ., " start� loopy 'a1. <. � end, ioopVari +±) C
ýýýý° ýý° , ýýýaýaýMý"ý'ýýý. ýý ý, ý ýý ý ,ýý. ýýý, ý ° ý° ý", ý ý' , ý-ý .ý opV, ar2+ ýý for
. ýýýooýýý" ýaý
ýý ý iý ý"'' ýý_ý. end ýý. rýýl ; ýC,,, ýý, rýý ý
ý
cout « space;
I
ý� ý'ý'ýýý1ý.., ý. y' ýýti ° ý.. ý"ýýýýýý"a x'ý. µ ýý
for (: LooýVäx3 .. start; Loopvar: i <= iýýýýýýýVarix . IooýVýýr3"ý-ý ) ýýý ý
y`.
couT+' « MJýýIrFýJýýýýiýM ii..
'
FIGURE Q2
[5 marks)
TBBI 073/iABi O1 3
a. ýrý ýýý ýýýiaýýýýýý mt number[} = {2,8,11,
ýýýýýýý the ýýýýowýng»
wý ýýr
The dec'ared size of the array.
ý I
, ý)I
(1 marlcj The range of values an index accessing this array irr have.
[1 mark]
bY Trace and write the output of the following C++ code fragment:
int, i, j, 'ý emp[8J ;
for ý Y. _,.
5"; I >':.. 0; : i--)
ý ýýýý [i] "" 3*1. ;
< 6; .i
if2)
riurn . push,,. ýýýýý
ýýý temp [ 1] ); rý
for (i _ 0; i ""w, 6; i
ýý
. ýý ., ý. ý ýor(j = 0, ý j<. ýýýms: x, ' zeQ; ýý
cout « terrrý [i] + rýýýýnf: ý j<
ý rout « e, nd. i;
[5 marks)
ck ýýýý ý function that accepts an array of 7 integer values. if the vaiue is
a prime number, it will be added to a vector. This function shou'd return
ý ýýýýýý of prime numbers.
t3 marks]
In the Eureka engineering project competition organized by UTP, seven judges award a score between 0 and 10, where each score may be a floatingpoMnt valuew The highest and the �owest are thrown out and the
remaining scores are added together The sum is then mutphed by the degree of difficulty for that project. The degree of difficu'ty ranges from
6
TBB1O73ITAB1 013
I w0 to 5.5 points. The total is then muItMplied by O6 to determine
project's score.
Write a C++ program that retrieves inputs from seven judges, score and
a degree of difficulty. The output of the program is the overa$ score for
a project.
[10 marks)
7
Týý ýý ýýýýýý ý O1 3
4. a. State ONE (1) reason why Functions are used in computer programs. [2 marks]
h. Exp4ain the following function prýýýýýe declaration.
void ýýýýýýonýabc(vogd)
[2 marks]
ii float Function_ýýc Qnt b, float h)
[2 marks]
iäL ýýýý ýunctionýabc (mt costfi 03)
[2 marks]
cä. What is the difference between g)obal varýýýýý and ýýý1 varýýýýe?
[2 marksj
IL Ana'yze the C++ code segment in ýýýýýý Q4a to determine
, the final value of Van and Var2 respectiveIy
ýýý ýýýý = 0,
void gýütal_Icaca1 (void)
ý
{ äýý ýar2= 1;
ýýýt « G(obaIr Varabe ý "' « Van,
cou°t ýý ý LocaN' ýýýýýýý ýý ýý ýýr2 »
Var1+1n
Var2+2,; ýýt maEn()
getýhý;
return 0; }
g1ýýýýýýýý();
Iýt iy
lor(i=O; ý"ýýý ++)
FIGURE Q4a
8
IýB1 073/iAB'1I OI 3
[3 marks]
d You are required to write ý ý++ program to
. accept three integers from user,
ýýýýýýate and display the average of these integers,
. caH a function to determine the aargest integer accepted, find the difference between the largest integer and the average caIculated, and then dIspIay the 'difference on
. screen
You may use the function n FIGURE Q4b n your programw
ýýý ýýýýý
float duff;
ýýýN = nlw
if (n2 > maxN)
ýýýý = ri2;
if (n3 > maxN)
ýýýý = ii3;
ýýff ý (float) rnaxN avg;
return dff,
FIGURE 4b
[7 marks]
TBBI 073/TAB1 01 3
5. a Give an example for each of following re(ationships.
I. Many-to-One
[1 markj ii. One-toOne
[1 mark idL OnetoMany
[1 mark] iv. ýýýy4oMany
[1 mark]
b. Give SQL statement which ýýýýýýý ý STUDENT table consisting of foiaowing fieldsM
L Name CHAR(40) ii Class CHAR(6) iii, Marks NUMBER(4)
Rank CHAR(8)
[4 macs]
c. You are required to create a conceptual data mod& for Computer
Information System department in Unlversitl Tekn+ýlogi Petrorias that
specializes in IT project consultatlonw The department has 40
consultants comprised of certified technologlst and can handle up to
I 50 ciients per year. Each client can request for consuItaton on either
one of the five types of IT project. Each of the projects will be handled
by a consuftatlon team of four to five technologists. Each technologist
is assigned to a maximum of four consultation teamsw
Identify the main entities possible to the ýýýýýýent.
[4 marks]
IL Identify the main relationship types and specify the cardinatity
for each rýýýýýonship. (4 marks
"10
TBB1 073ITAºB1 01 3
iii. Using your answers in part (a}(i) and part (a)(ii), draw a single Entity Relationship (ER) diagram to represent the data
requirements for the company. Use Chen Model notation.
[4 ma rksj
-END OF PAPER-
I '1