Skip to document

Diploma in IT - Programming 3A - Memo

Diploma in IT - Programming 3A - 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.

Related Studylists

Magau exams

Preview text

Programming 3A Sick Test Memorandum Page 1 of 12

Programme Diploma in Information Technology

Module Programming 3A

Module Code 22_HE_FT_DP_IT_PRG

Module NQF Level 7

Credits 15

Exam Deferred Test Memo

Semester 1 ST

Date Written 03 MAY 2022

Total marks 140

Duration 3 HOURS

Pass mark 50%

Weighting 20%

Examiner Neelofar Mahomed Hoosen

Moderator Tshepo Gutamo

This question paper consists of 12 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: 60 marks

2. Section B: 10 marks

3. Section C: 70 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 Sick Test Memorandum Page 2 of 12

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 Sick Test Memorandum Page 4 of 12

Short Questions QUESTION 2 (40 marks)

2 List the nine Integral data types. byte, sbyte, short, ushort, int, uint, long, ulong, and char. √√√√√√√√√

(9)

2 How would you compare C# with Java? C# is very similar to Java because Java was also based on C++. However, C# is more truly object oriented. √ Unlike in Java, every piece of data in C# is an object, providing all data with increased functionality. √ In Java, simple data types are not objects; therefore, they do not work with built-in methods. Additionally, in Java, data can only be passed to and from methods using a copy; C# omits this limitation. √

(3)

2 Briefly explain four common Errors programmers might make when using decision making structures.

  • Using the assignment operator (=) instead of the comparison operator ( ==) when testing for equality. √

  • Inserting a semicolon after the Boolean expression in an if statement instead of using it after the entire statement is completed √

  • Failing to block a set of statements with curly braces when several statements depend on the if or the else statement. √

  • Failing to include a complete Boolean expression on each side of an && or || operator in an if statement. √

(4)

2 How is a named constant different from a variable and how would you create a named constant? Include an example of a constant declaration in your answer.

By definition, a variable's value can vary, or change. √Sometimes you want to create a named constant (often simply called a constant), an identifier whose contents cannot change. √ You create a named constant similar to the way you create a named variable, but by using the keyword const. √ Although there is no requirement to do so, programmers usually name constants using all uppercase letters, inserting underscores for readability. √This convention makes constant names stand out so that the reader is less likely to confuse them with changeable variable names. √ For example, the following declares a constant named TAX_RATE that is assigned a value of 0: const double TAX_RATE = 0; √

(6)

2 Explain why implicit numeric conversions are necessary and how C# chooses operands to conver?.

(6)

Programming 3A Sick Test Memorandum Page 5 of 12

When you perform arithmetic with variables of the same type, the result of the arithmetic retains that type. √For example, when you divide two ints, the result is an int. Often, however, you need to perform mathematical operations on different types. √For example, you might need to multiply an int by a double. √ In this case, C# chooses a unifying type for the result and implicitly converts nonconforming operands to the unifying type, which is the type with the higher type precedence. √√ In the case of multiplying an int by a double, the result will be a double. √

2 What is an unwanted event-handling method(orphan method) and what steps are required to delete it?

When you are working in the Form Designer in the IDE, it is easy to inadvertently double- click a control and automatically create an event-handling method that you do not want. For example, you might double-click a Label named label1 by mistake and generate a method named label1_Click().√

Such empty methods that never execute are known as orphaned methods. You should not just delete an orphaned method because, behind the scenes, other code might have been created that refers to the method; if so, the program will not compile. √

Instead of deleting the method code, you should click 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. This eliminates all the references to the method, and your program can again run successfully. √√

You also double click on the error in the error list window. Go to designer and delete the reference to the unwanted method before deleted the method altogether. √√

(6)

2 Briefly compare GUI and console applications, in your answer describe how would you choose which is more appropriate for a given task?

  • GUI applications look "snazzier." It is easy to add colours and fonts to them, and they contain controls that a user can manipulate with a mouse. √

  • Also, users are accustomed to GUI applications from their experiences on the Web. √

  • However, GUI programs usually take longer to develop than their console counterparts because you can spend a lot of time setting up the controls, placing them on a Form, and adjusting their sizes and relative positions before you write the code that does the actual work of the program. √

  • GUI applications created in the IDE also require much more disk space to store. √

  • Console applications look duller, but they can often be developed more quickly because you do not spend much time setting up objects for a user to manipulate. √

  • When you are learning programming concepts like decision-making and looping, you might prefer to keep the interface simple so that you can better concentrate on the new logical constructs being presented. √

(6)

Programming 3A Sick Test Memorandum Page 7 of 12

SECTION C: PRACTICALS

QUESTION 4 (15 Marks)

Create an enumeration named Month that holds values for the months of the year, starting with JANUARY equal to 1. Create a console application that prompts the user for a month integer. Convert the user’s entry to a Month value, and display a message as seen below.

using System; using static System; class MonthNames { enum Month { JANUARY = 1, FEBRUARY, MARCH, APRIL, MAY, JUNE, JULY, AUGUST, SEPTEMBER, OCTOBER, NOVEMBER, DECEMBER } static void Main() { int monthNum; Month monthWord; Write("Enter a month number >> "); monthNum = Convert(ReadLine()); monthWord = (Month)monthNum; WriteLine("{0} is month {1}", monthWord(), monthNum()); ReadKey(); } }

Programming 3A Sick Test Memorandum Page 8 of 12

QUESTION 5 (10 Marks)

Write a C# Gui application that requests the current salary amount from the user and store in a variable, include a named constant representing next year’s anticipated 4 percent raise. Display with explanatory text, next year’s salary of the employee.

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

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

private void Button1_Click(object sender, EventArgs e) { const double RAISE = 0; double salary = Convert(textBox1); outputLabel = "$" + salary + " plus " + (RAISE * 100) + " percent raise is $" +

Programming 3A Sick Test Memorandum Page 10 of 12

QUESTION 7 (30 Marks)

Write a program console menu-driven application to function as seen below. Allow the user to enter two integers and which arithmetic operation they would like to work with and display the result as seen below. If zero is entered as the second integer then display a message as seen in Figure 2 and terminate the application. No extra validation is required.

Figure1.

Figure 2.

using System; using static System; public class Exercise {

Programming 3A Sick Test Memorandum Page 11 of 12

public static void Main() { int num1, num2, opt;

Console("\n"); Console("A menu driven program for a simple calculator:\n"); Console("------------------------------------------------"); Console("\n\n");

Console("Enter the first Integer: "); num1 = Convert(Console()); Console("Enter the second Integer: "); num2 = Convert(Console());

Console("\nHere are the options :\n"); Console("1-Addition.\n2-Subtraction.\n3-Multiplication.\n4-Division.\n5-Exit.\n"); Console("\nPlease choose an arithmetic operation: "); opt = Convert(Console());

switch (opt) { case 1: Console("\nThe sum of {0} and {1} is: {2}\n", num1, num2, num1 + num2); break;

case 2: Console("\nThe difference of {0} and {1} is: {2}\n", num1, num2, num1 - num2); break;

case 3: Console("\nThe product of {0} and {1} is: {2}\n", num1, num2, num1 * num2); break;

case 4: if (num2 == 0) { Console("The second integer is zero.\nInvalid divisor.\nWe cannot Divide by zero therefore we will now terminate the application\n");

}

else { Console("The quotient of {0} and {1} is : {2}\n", num1, num2, num1 / num2); } break;

case 5: break;

}

ReadKey();

Was this document helpful?

Diploma in IT - Programming 3A - Memo

Course: Programming

119 Documents
Students shared 119 documents in this course

University: Damelin

Was this document helpful?
Programming 3A Sick Test Memorandum Page 1 of 12
Damelin©
Programme
Diploma in Information Technology
Module
Programming 3A
Module Code
22_HE_FT_DP_IT_PRG310
Module NQF Level
7
Credits
15
Exam
Deferred Test Memo
Semester
1ST
Date Written
03 MAY 2022
Total marks
140
Duration
3 HOURS
Pass mark
50%
Weighting
20%
Examiner
Neelofar Mahomed Hoosen
Moderator
Tshepo Gutamo
This question paper consists of 12 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:
60 marks
2.
Section B:
10 marks
3.
Section C:
70 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.