Prog (C++) 621 (P)

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

.

RICHFIELD GRADUATE INSTITUTE OF TECHNOLOGY (PTY) LTD

HIGHER EDUCATION AND TRAINING

FACULTY OF INFORMATION TECHNOLOGY

PROGRAMMING 621 (PRACTICAL)

1ST SEMESTER NATIONAL CA TEST 2

DURATION: 1 HOUR MARKS: DATE: 30 MAY 2018

EXAMINER: MUSA SHEZI MODERATOR: EMMANUEL MANY

This paper consists of 4 questions and 2 pages including this page.

PLEASE NOTE THE FOLLOWING:


1) Ensure that you are writing the correct CA TEST paper, and that there are no missing pages.
2) You are obliged to enter your student details on the answer booklet. The answer booklets provided are
the property of the Richfield Graduate Institute Of Technology and all extra booklets must be handed to
the invigilator before you leave the examination room.
3) If you are found copying or if there are any documents / study material in your possession, or writing on
parts of your body, tissue, pencil case, desk etc., your answer booklet will be taken away from you and
endorsed accordingly. Appropriate disciplinary measures will be taken against you for violating the code of
conduct of Richfield Graduate Institute of Technology Examinations Board. Therefore, if any of these
materials are in your possession you are requested to hand these over to the invigilator before the official
commencement of this paper.
4) The question paper consists of 3 sections.
a. Sections A is online and compulsory.
b. Section B comprises of 3 questions, you are required to answer any 2 questions.
SUGGESTED TIME REQUIRED TO ANSWER THIS QUESTION PAPER
NUMBERS QUESTIONS MARKS TIME IN MINUTES
SECTION A: MULTIPLE CHOICE QUESTIONS COMPULSORY

1 Question One – Online 50 60


SECTION B: COMPULSORY
2 Question Two 20 25
SECTION C: ANSWER ANY ONE QUESTION
3 Question Three 30 35
4 Question Four 30 35
TOTAL 100 120

Initiated By Academic Director Dr Muni Kooblal Document No CA Test 2 /01/2018


Authorised By Group Chief Executive Officer Mr J Ramnundlall Revision No 01/2015
Issuing Office Head Office – Main Campus CONTROLLED COPY Revision Date 02/05/2018
Document PROG(C++)_621 (P) Issue Date 02/05/2018

Page 1 of 2
SECTION B (COMPULSORY) (20 MARKS)

QUESTION TWO

2.1 Write a program that reads a Celsius degree in a double value from the console, then converts
it to Fahrenheit and displays the Result. The formula for the conversion is as follows:
Fahrenheit = (9 / 5) * Celsius + 32
Hint: In C++, 9 / 5 is 1, but 9.0 / 5 is 1.8. (10)

2.2 Write a program that reads in the radius and length of a cylinder and computes the area and
volume using the following Formulas:
Area = radius *
radius * p Volume
= area * length

Use the Math class from C++ to handle P for a pie constant. (10)

SECTION C (ANSWER ANY ONE QUESTION FROM THIS SECTION) (60 MARKS)

QUESTION THREE (30 MARKS)

3.1 Write a program that reads an integer between 0 and 1000 and adds all the digits in the integer.
For example, if an integer is 932, the sum of all its digits is 14.
Hint: Use the % operator to extract digits, and use the / operator to remove the extracted digit.
For instance, 932 % 10 = 2 and 932 / 10 = 93. (15)

3.2 Write a program that prompts the user to enter a three-digit integer and determines whether it
is a palindrome number. A number is palindrome if it reads the same from right to left and from
left to right. (15)

QUESTION FOUR (30 MARKS)

4.1 Write a method that computes the sum of the digits in an integer. Use the following method
header: public static int sumDigits(long n)
For example, sumDigits(234) returns 9 (2 + 3 + 4). (Hint: Use the % operator to extract digits,
and the / operator to remove the extracted digit. For instance, to extract 4 from 234, use 234
% 10 (= 4). To remove 4 from 234, use 234 / 10 (= 23). Use a loop to repeatedly extract and
remove the digit until all the digits are extracted. Write a test program that prompts the user
to enter an integer and displays the sum of all its digits. (30)

TOTAL MARKS: 50

Initiated By Academic Director Dr Muni Kooblal Document No CA Test 2 /01/2018


Authorised By Group Chief Executive Officer Mr J Ramnundlall Revision No 01/2015
Issuing Office Head Office – Main Campus CONTROLLED COPY Revision Date 02/05/2018
Document PROG(C++)_621 (P) Issue Date 02/05/2018

Page 2 of 2

You might also like