0% found this document useful (0 votes)
112 views9 pages

Answer Sheet Csc128 Test 1 March2020

Uploaded by

mimi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
112 views9 pages

Answer Sheet Csc128 Test 1 March2020

Uploaded by

mimi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

CONFIDENTIAL CS/MAC-JULY 2020/CSC128

UNIVERSITI TEKNOLOGI MARA


TEST 1 (ANSWER SHEET)

COURSE : FUNDAMENTALS OF COMPUTER PROBLEM


SOLVING
COURSE CODE : CSC128
DATE : 10 JUNE 2020
TIME : 2 HOURS 50 MINUTES

INSTRUCTIONS TO CANDIDATES

1. This question paper consists of FIVE (5) questions

2. Answer ALL questions.

* PLEASE ANSWER IN THIS ANSWER SHEET THEN SAVE THIS FILE IN PDF FORMAT
* RENAME THIS FILE AS YOURFULLNAME_ANSWER SHEET_CSC128_TEST 1.PDF
* Please fill all this information below.

NAME :

STUDENT ID :

GROUP :

For Examiner’s
Used Only
Q1 /7
Q2 / 10
Q3 /8
Q4 / 10
Q5 / 15

Total / 50

DO NOT TURN THIS PAGE UNTIL YOU ARE TOLD TO DO SO

This examination paper consists of 9 printed pages


© Hak Cipta Universiti Teknologi MARA CONFIDENTIAL
CONFIDENTIAL 2 CS/MAC-JULY 2020/CSC128/TEST1

Answer ALL questions.

QUESTION 1(7 MARKS)

a. Briefly explain the definition of counter-controlled loop. (2 marks)

ANSWER:

b. Write a complete C++ program for the following pseudocode:

Start
Set total = 0
Set i=0
While (i < 10 )
Display “ Enter a mark: “
Get mark
Add the mark into total
Add one to i
EndWhile
Average = total / 10
Display “The total mark: “,total
Display “The average : “,Average
End

(5 marks)

ANSWER:

QUESTION 2 (10 MARKS)


© Hak Cipta Universiti Teknologi MARA CONFIDENTIAL
CONFIDENTIAL 3 CS/MAC-JULY 2020/CSC128/TEST1

a. Write a program that prompts the user to enter a series of numbers that ends with
zero. The program has to do the following calculation and print the results.

 Count the number of data that is divisible by 6.


 Determine the smallest number given by the user.

(6 marks)

ANSWER:

b. Write a program using the for loop that will produce the following multiplication
table:
© Hak Cipta Universiti Teknologi MARA CONFIDENTIAL
CONFIDENTIAL 4 CS/MAC-JULY 2020/CSC128/TEST1

1X2=2
2X2=4
3X2=6
4X2=8
5 X 2 = 10
6 X 2 = 12
7 X 2 = 14
8 X 2 = 16
9 X 2 = 18
10 X 2 = 20

(4 marks)
ANSWER:

QUESTION 3 (8 MARKS)

What is the output of the following C++ codes? *Notes : use tracing table*

a. for (a = 3; a <= 24; a = a * 2)


cout << a << “ “;
(2 marks)
ANSWER:

b. int i = 2;
while (i < 3) {
© Hak Cipta Universiti Teknologi MARA CONFIDENTIAL
CONFIDENTIAL 5 CS/MAC-JULY 2020/CSC128/TEST1

cout<<“hi ”;
i++;
}
cout<<“bye”;)
(2 marks)
ANSWER:

c. for(row=1; row<=4; row++)


{
for (column=1; column<=4; column++)
{ if (row==1 || row==4)
cout<<"*";
else
if (column==1 || column==4)
cout<<"*";
else
cout<<" ";
}
cout<<endl;
}
(4 marks)
ANSWER:

QUESTION 4 (10 MARKS)

© Hak Cipta Universiti Teknologi MARA CONFIDENTIAL


CONFIDENTIAL 6 CS/MAC-JULY 2020/CSC128/TEST1

Raub Roadways Bhd. is starting a bus transportation business which offers trips from Raub
to multiple destinations in east coast region. In order to improve their services, Raub
Roadways Bhd. plans to develop an online ticketing system which enable their passengers
to travel with ease. The following table shows the details of each trip:

DESTINATION DEPARTURE ARRIVAL TICKET


DESTINATION
CODE TIME TIME PRICE
A Kuantan 9:30 am 13:30 pm RM23.50
B Kuala 10:30 am 15:30 pm RM41.00
Terengganu
C Kota Bharu 11:30 am 18:30 pm RM46.00

This program will allow user to input the destination code and quantity of tickets.
This program should display the details of the chosen destination (destination,
departure time, arrival time, ticket price and total price to be paid by the
customer. (Note: Display an error message for any invalid destination code). Write a
complete C++ program based on the given format of input and output as the following
sample output:

ANSWER QUESTION 4:

© Hak Cipta Universiti Teknologi MARA CONFIDENTIAL


CONFIDENTIAL 7 CS/MAC-JULY 2020/CSC128/TEST1

QUESTION 5

Damai Bayu Resort offers a variety of packages for the wedding auditorium to their
customers. Payments are based on the type of package and the amount of hours spent. An

© Hak Cipta Universiti Teknologi MARA CONFIDENTIAL


CONFIDENTIAL 8 CS/MAC-JULY 2020/CSC128/TEST1

additional RM50.00 per guest will be charged for meals. The details of the charges for
each package are shown in the following table:

Type of Package Name of Package Price / hour (RM)


1 Pearl (basic) 300
2 Ruby (sound Effects) 550
3 Platinum (sound and lighting effects) 750

a) Write a main program to do the following:


 Input the type of package, number of hour spent and number of guests.
 Calculate the totalPayment of the package with the additional charges for meals. A
discount of 20% will be given if the total payment is more than RM5000, while a
10% discount is given for other amount.
 Display the total payment for a customer.
 The program will ask the user to enter Y-yes for continue and N-No for end the
system. At the end of the process, display the number of each package that
customer chooses and the total sales from all customers.

(15 marks)
ANSWER:

© Hak Cipta Universiti Teknologi MARA CONFIDENTIAL


CONFIDENTIAL 9 CS/MAC-JULY 2020/CSC128/TEST1

END OF QUESTION PAPER

© Hak Cipta Universiti Teknologi MARA CONFIDENTIAL

You might also like