Você está na página 1de 4

UNIVERSITY OF TECI-INOLOGY, JAMAICA

and Computing

FACULTY:

Eugineertng

SCHOOL:

Computing &

Final/ Redn Examina tiou, Semester

Information

Technology

Module Name:

Programming

Module Code:

CMPI024

Date:

April,20l2

Theory/ Practical:

Theory

Groups:

BSCl, Franchise (Community Colleges)

Duration:

2 hours

INSTHUCTIONS
1. Answer all questions in Section [ and any two (2) from Section II of this test
a. Answer Sections I and )[ in the Answer Booklet provided
2. The total marks for each Section is stated in brackets at the start of that Section
3. All working must be clearly shown.
4. Silent electronic calculators may be used [Of this test.
5. This paper is marked out of a total of 75 ilt:t r ks.

no NOT

TURN THiS rACE

UNTIL YOU ARE TOLl) TO DO SO

Page

1 of 4

t '

COMl'liLSOHY
QlmSTlONS
ITOTAL = 25 marks]

Sectiuu 1- Auswcl' ALL qllcsliol1s


Answer !III questions

Justrncriuns:
1.

Answer

all questions

A) Using nested

within the Answer

Booklet

for a total of25

marks.

list cd below: -

for loops.write the pseudocode segment that will display the following:

~.

-J.:

**

B) A C program contains

the following

dcclarntious:

f16at mo, yz, rt;


int

x,

y,

z:

EA.CH

Write a single C statement


i.
II.

accept user-input

that will:

values for y and yz

increase mo by a quarter of

iii.

print the rt as a currency

IV.

use the couditional


mo is not positive.

1110

value in the format: $999999.99

rpcrlltqr

10 assign y to x if mo is positive;

but assign z to x if

II +1+ I +2f/1lJr~sJ
C) By tracing, show the state of each varialx., lX, Y IJfU( z) in every line for the following
pseudocode-segment
(NOTE: Each line affects the variable's value/or the next line) : l.

2.
3.
4.
5.
6.

DECLARE
LET Z ~
LET x ~
LET Y
LET z ~
LET x ,_.

x, y, Z AS WHOLE
24 / 5
Z
% ( Z + 3)
0 + x / 3 -t- z
x / y / z
(z - x) / 4
Z -I-

[5 l1I(lr{(s)
J)) It is suggested that you can tell someone's personality based on the first letter in their
first names. What follows is a table that have some of the first letters: -

",H

'N

Athletic

'E'

Elegant

'F'

Foxy

Others

Philosophical

[)esigl~th~-~-cgnle~;t ~f tr;efl;;W-ch"rt(Y;~~-d;~(~i71al'c
to write the ell/ire program
design) that will display a message indicating a PEl{SONALlTV
based on a
character value thai represents the FIRST LETTER of the FIRST NAME using:
i.
The LINEAR/SEQUENTIAL
IF design.
[6 !ll1I"k~'1
II.
The CASE design.

Page2of4

ESSAY ITEMS
ItOtAL
= 50 marks]

Sectiollll-

Ailswer ANY

lnstructlons:

2.

rwo
(2) questions.
--~~--------------------------------------

Answer any two (2) questions within the Answer


50 marks, Four (4) questions are provided.

Bonklet

provided

for a total of

[C code Analysis]
Consider

the following

program solution

written in C.

ftinclude <stdio.h>
void main(void)
{

int year;
int popl;
const int curryear
= 2012;
printf
("Please enter the current
population:");
scanf
("%d", &popl);
printf
("YEAR
POPULATION\n=======================\n\n")
for (year = 5; year>
0; year -= 1)

printf
("%4d
popl += popl

%06d\n",

(curryear

- year),

A) Using a Trace Table, show the contents of each variable


above program

popl);

% year;

& what will be displayed

by the

if the user enters: 23 as tile current population.

Iis marks]

13) Design the Pseudocode

that performs

the same task as the above program.

r 10 1II(O'I<s]
3.

[Decision

"Employees

Tables]
at Greggs Ltd work a set number of hours related to the following:

workers work for 5 hours a day as long as their salaries are below $ 15,000.00.
work for 5 hours a clay. Anyone with salaries above $60,000.00

All female
All male workers

must work on weekends.

All

males with salaries equals to or less than $GO,OOO.OO get a maximum

of7 hours overtime.

Any

worker with salaries bet ween $15,000.00

also get a maximum

of 7

and $60,000.00

(inclusive)

hours overtime."

A) Construct

a decision

above program's

table, simplifying

the conditions

and outcomes

to be used in the

design.
(22 matksl

B) Ilow many columns


problem?

would you have used if there were 6 unique conditions

within the

Justify the reason for the formula used for your answer.

1.1 Illm1'5]

I'age 301" 4

4.

[Pscudocoi\cl

A dating service wants to be able to find matches


YOIl to build a system that will match customers

For its customers.

They have commissioned

based On the following information:

NOTE; The company wants the program to calculate and output the 101;11
numhcr

of compatihle

matches

that were made below.

First, prompt the user for the total number

For each record to be processed,

of records

to be processed.

gender, agc

YOII should accept the custumcris

and hcight.
,

The system must validate the gender

to make sure that it is only 'M' or '1"'. Ifthe

gender is not valid then an appropi-iate


'F' to the variable and then continue

errnr

message

must be printed, assign

with the rest of the system.

The system must validate the age to make sure that it falls within the range ofln
to 60 (inclusivev. If the age is not valid then an ,lpprnprio,lc er'rnr mcssagc
be printed, assign 60 to the variable ami then continue

"

The system must then accept a customer's

gender,

must

with the rest of the system.

ilgc and height

from the user.

Assume that the entered information is valid.

The system must then displuy


inputted customer

is compatihle

an appropriate

message

or incomputihle

stating whether the

with the record ill the database.

as long as they have different

geuners; their heights

Customers

are compatible

are within

l' (one foot) of each other; and their ages are the same.

HEQIJIHE));
Write the pseudocode

5.

corresponding

to the design requested

by SOM8.

[Fluwchart]
A) Design the flowchart
between

vnriubles

that uses a loop to display


Y and z (inciusivei.

all of the multtples

of

a variable

(Declare any variables needed before use)

For example: x = 3, J' = 4, Z = 12; output is: 6 9 12

P 5 marks]

ll) Design the Flowchart

fill'

a system

that prompts

for a positive

and prints out the slim or all squares from I to (and including)
allY

integer, then computes


the integer.

(Declare

variables needed before lIse)

r 10 marks I

Page 4 of -l

Você também pode gostar