Skip to document

Programming 3A Exam Memo

Programming 3A Exam Memo
Course

Programming

119 Documents
Students shared 119 documents in this course
University

Damelin

Academic year: 2023/2024
Uploaded by:
Anonymous Student
This document has been uploaded by a student, just like you, who decided to remain anonymous.
Damelin

Comments

Please sign in or register to post comments.

Preview text

Programming 3A Exam Memorandum Page 1 of 17

Programme Diploma in Information Technology

Module Programming 3A

Module Code PRG

Module NQF Level 7

Credits 15

Exam Exam Memorandum

Semester 1 ST

Date Written 21 June 2021

Total marks 140

Duration 3 Hours

Pass mark 50%

Weighting 20%

Examiner Neelofar Mahomed Hoosen

Moderator Tshepo Gutamo

This question paper consists of 17 pages including the cover page.

REQUIREMENTS:

Learner Requirements: Stationery and Examination Answer booklet

Equipment Requirements: PC with Visual Studio

This paper consists of:

1. Section A: 55 marks

2. Section B: 14 marks

3. Section C: 71 marks

ALL sections are COMPULSORY. It is in your own interest to write legibly and to present your work

neatly.

PLEASE READ THE ASSESSMENT RULES AND REGULATIONS THAT FOLLOW

Learners are warned that contravening any of the examination rules or disobeying the instructions of an

invigilator could result in the examination being declared invalid. Disciplinary measures will be taken

which may result in the students’ expulsion from Damelin.

Programming 3A Exam Memorandum Page 2 of 17

ASSESSMENT RULES AND REGULATIONS

Please ensure that you have read and fully understand the following assessment rules and regulations

prior to commencing with your assessment:

1. To be permitted access to the examination, a learner must arrive with:

- an Identity Document or other official proof of identity (for example,

- a student card, passport or driver's licence card with photo); and

- the required exam stationery.

2. No learner may enter the examination room more than 30 minutes after the examination sitting has

commenced and no candidate may leave the room less than one hour after the examination sitting

has commenced.

3. No extra time will be allowed should a student arrive late.

4. All learners must sign the Attendance Register for the examination on arrival.

5. It is the responsibility of learners to familiarise themselves with the examination rules prior to sitting

for the examination.

6. All examinations are to be written on the date and time officially stipulated by the College.

7. It is the responsibility of learners to ensure that they are writing the correct paper and that the

question paper is complete

8. Cell phones must be switched off prior to entering the exam venue. Cell phones and wallets may

be placed under candidates' chairs rather than at the front of the room.

9. Learners may not handle cell phones or wallets during the exam.

10. No weapon of any description may be taken into the assessment room.

11. All personal belongings are to be placed at the front of the examination room. Personal belongings

brought to the examination are at the owner's risk.

12. Smoking is not permitted, and learners will not be allowed to leave the examination room in order

to smoke

13. Once the examination has commenced, all conversation of any form between candidates must

cease until after candidates have left the room, after the examination.

14. Only the official College examination book, as supplied by the College, may be used.

15. Learners must ensure that their student number is written on the answer book.

16. Learners are responsible for ensuring that they follow the instructions in the examination for

submitting their answers.

17. Please read the instruction appearing on the examination paper carefully

18. The number of every question must be clearly indicated at the top of every answer.

19. No pages may be torn out of the answer book. All question papers and scrap paper must be

handed to the invigilator after the examination.

20. Learners finishing earlier are to leave the examination room as quietly as possible on the

instruction of the invigilator and may not talk until outside the building where the examination is

being written.

21. Only under exceptional circumstances will a learner be permitted to leave the examination room

during the examination, and if the invigilator gives permission. An invigilator must accompany the

learner. Only one learner at a time may be absent from the examination room.

22. Candidates may not act dishonestly in any respect.

Programming 3A Exam Memorandum Page 4 of 17

Short Questions

QUESTION 2 (35 marks)

2 Briefly describe how you would go about compiling and running your C# class in command prompt.

Locate and run the developer command. √ Change the path to the location of your file and then type csc, followed by the name of the file that contains the source code with the extension. √ If you receive no error messages after compiling the code, then the program compiled successfully, and a file with the same name as the source code—but with an .exe extension—is created and saved in the same folder as the program text file. √√ To run the program from the command line, you simply type the program name —for example, Exercise1. √

(5)

2 For a language to be considered object-oriented, What features must it support? Classes√ Objects√ Encapsulation and Interfaces√ Inheritance√ Polymorphism√

(5)

  1. List and explain with an example each comment used in C#. Line comments - start with two forward slashes ( // ) and continue to the end of the current. √ e. //This is a comment√ Block comments - start with a forward slash and an asterisk ( /* ) and end with an asterisk and a forward slash ( */ ). √ e. /This is a comment End of comment/√

XML-documentation format comments- use a special set of tags within angle brackets processed by the compiler to generate an XML documentation file at compile time. Starts with /// and has (<>)√ e. ///<summary>Credit account with amount passed as parameter</summary> √

(6)

  1. What does the second number within the curly braces in a format string, represent? Alignment√ and field size√

(2)

Programming 3A Exam Memorandum Page 5 of 17

  1. Briefly explain how you would go about deleting an unwanted event-handling method in C# using the properties window in Visual studio?

Click/select the control with the unwanted method so it appears in the Properties window√, then click the Events button, which looks like a lightning bolt. √ Select the event you want to eliminate, and delete the name of the method. √

(3)

  1. Draw a Truth table depicting the logical && operator

√√√√√

(5)

  1. What is the main difference between the between Boolean logical AND operator, the Boolean logical inclusive OR operator and the (conditional AND and OR) operators. The Boolean logical AND operator ( & ) and Boolean logical inclusive OR operator ( | ) work just like their && and || (conditional AND and OR) counterparts √, except they do not support short-circuit evaluation. √That is, they always evaluate both sides of the expression, no matter what the first evaluation is. √

(3)

  1. When can we not use the Binary Search() as it would not work correctly?

If your array items are not arranged in ascending order. √ If your array holds duplicate values and you want to find all of them, the BinarySearch() can return only one value, so it returns the position of the first matching value it finds (which is not necessarily the first instance of the value in the array). √ If you want to find a range match rather than an exact match. √

(3)

  1. Which two methods should be used when sorting an array in Descending order? Array()√followed by Array()√

(2)

  1. Which access modifier allows access to the method from other classes. Public√

(1)

Programming 3A Exam Memorandum Page 7 of 17

jaggedArray[1] = new int[4] { 12, 42, 26, 38 } jaggedArray[2] = int[6] { 3, 5, 7, 9, 11, 13 }; jaggedArray[] = new int[3] { 4, 6, 8 };

for (int i = 0; i < jaggedArray; ) { Write("Element({0}):", i + 1); for (int j = 0; j < jaggedArray[i].Length; j++) { Write("{0}",jaggedArray[i][j]); }

}

} } }

using System; using static System; namespace Jagged_Arrays_example { class Program { static void Main(string[] args) {

int[][] jaggedArray = new int[ 4 ][]; jaggedArray[0] = new int[2] { 7, 9 }; jaggedArray[1] = new int[4] { 12, 42, 26, 38 }; jaggedArray[2] = new int[6] { 3, 5, 7, 9, 11, 13 };

Programming 3A Exam Memorandum Page 8 of 17

jaggedArray[ 3 ] = new int[3] { 4, 6, 8 };

for (int i = 0; i < jaggedArray; i++) { Write("Element({0}):", i + 1); for (int j = 0; j < jaggedArray[i].Length; j++) { Write("{0,5}",jaggedArray[i][j]); } WriteLine(); } ReadLine(); } } }

Programming 3A Exam Memorandum Page 10 of 17

{

enum Day { SUNDAY = 1, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY } static void Main() { int day; string message = "";

Write("Enter a number from 1-7 representing a day in the week "); day = Convert(ReadLine());

while (day <= 0 || day > 7) { WriteLine("Invalid number entered, please enter a day between 1-7"); day = Convert(ReadLine()); }

switch ((Day)day) { case Day: message = "It's Saturday the 1st day of the weekend"; break; case Day: message = "It's Sunday, tomorrow we go back to work"; break; case Day: message = "Monday Blues"; break; case Day: message = "It's Tuesday, 3 more days to go till the weekend"; break; case Day: message = "It's Wednesday, 2 more days to go till the weekend";

Programming 3A Exam Memorandum Page 11 of 17

break; case Day: message = "It's Thursday, 1 more day to go till the weekend"; break; case Day: message = "It's Friday, Few hours left till the weekend"; break;

}

WriteLine(message);

ReadKey(); } } }

Programming 3A Exam Memorandum Page 13 of 17

using System; using System.Threading; using System.Windows;

namespace FortuneTellerGUI { public partial class Form1 : Form { public Form1() { InitializeComponent(); }

public static void DisplayFortune(string first, string second) { MessageBox(String ("Your fortune:\n\n{0}\n\n{1}", first, second),"Fortune Prediction",MessageBoxButtons,MessageBoxIcon);

}

private void btnShow_Click(object sender, EventArgs e) {

string[] fortunes = {"I see a tall, dark stranger in your future.", "There will be some money coming your way.", "Happiness is just around the corner.", "You will travel to faraway lands.", "A younger person is about to make a big difference in your life.", "The number 3 is very significant for you."}; Random RandomClass = new Random(); int ran1, ran2; ran1 = RandomClass(0, fortunes); ran2 = ran1; while (ran2 == ran1) ran2 = RandomClass(0, fortunes);

Programming 3A Exam Memorandum Page 14 of 17

DisplayFortune(fortunes[ran1], fortunes[ran2]); } } }

QUESTION 6 (15 Marks) Write a c# application that requests a mark from the user between 0-100. Create two parallel arrays, one being an array named marks[] that contains six ranges of low limits. The second array is named grades[] containing values between A-F. The application should allow us to search for a range match by determining the pair of limiting values between which a user’s mark falls. Use the figure below as a guide as to what output should be seen.

75-100 ->A 70-74->B 60-69->C 50-59->D 40-49.>E 0-39->F

using System; using static System; using System.Collections; using System; using System;

Programming 3A Exam Memorandum Page 16 of 17

QUESTION 7 (16 Marks) Write a C# application that displays a table of the sum of every combination of two integers from 1 through 10 using right alignment.

using System; using static System; using System.Collections; using System; using System; using System.Threading; namespace DisplaySumTable { class DisplaySumTable { static void Main() { int first, second; const int LIM = 10; Write(" "); for (first = 1; first <= LIM; ++first) Write("{0, 5}", first); WriteLine(); for (int count = 0; count < 60; ++count) Write("_"); WriteLine(); for (first = 1; first <= LIM; ++first) { Write("{0,5}", first); for (second = 1; second <= LIM; ++second) Write("{0, 5}", first + second); WriteLine(); } ReadKey();

Programming 3A Exam Memorandum Page 17 of 17

}

}

}

Markers to use their discretion with variable names, alternative approaches, and statements provided that the instructions per question are followed. ∞End of Question Paper Memorandum∞

Was this document helpful?

Programming 3A Exam Memo

Course: Programming

119 Documents
Students shared 119 documents in this course

University: Damelin

Was this document helpful?
Programming 3A Exam Memorandum Page 1 of 17
Damelin©
Programme
Diploma in Information Technology
Module
Programming 3A
Module Code
PRG310
Module NQF Level
7
Credits
15
Exam
Exam Memorandum
Semester
1ST
Date Written
21 June 2021
Total marks
140
Duration
3 Hours
Pass mark
50%
Weighting
20%
Examiner
Neelofar Mahomed Hoosen
Moderator
Tshepo Gutamo
This question paper consists of 17 pages including the cover page.
REQUIREMENTS:
Learner Requirements: Stationery and Examination Answer booklet
Equipment Requirements: PC with Visual Studio
This paper consists of:
1.
Section A:
55 marks
2.
Section B:
14 marks
3.
Section C:
71 marks
ALL sections are COMPULSORY. It is in your own interest to write legibly and to present your work
neatly.
PLEASE READ THE ASSESSMENT RULES AND REGULATIONS THAT FOLLOW
Learners are warned that contravening any of the examination rules or disobeying the instructions of an
invigilator could result in the examination being declared invalid. Disciplinary measures will be taken
which may result in the students’ expulsion from Damelin.