CSharp - Revision Past Paper - 2019 - With Answers
CSharp - Revision Past Paper - 2019 - With Answers
PROGRAMMES :
Instructions to candidates
Question 1
a) Study the following program code and answer the questions that follow.
i. Rewrite the above program using if .. else if conditional structure [10 Marks] Answer:
ii. State one disadvantage of using Text Files For data persistence. [2 Marks]
- Text Files have variable length fields making it difficult to mark where fields start and
end
- 2 marks for the correct answer
Question 2
Answers :
i. C#, VB.Net, C, C++, F#, JavaScript - 1 mark each correct, max 3
ii. Compiler - 2 mark
Answers :
i. Flowchart Symbols ( 1 mark for each correct answer – max 5)
Question 3
ii. For each of the stages identified in i. above explain its purpose and name the
group of people who accomplishes it. [10 Marks]
Answers (1 mark each for purpose, 1 mark for the people working on it, max 2):
iii. Requirements gathering – gathering system specifications so that the system
may perform as required by users.
Personnel – System Analysts
iv. Planning/Design – preparing the system architecture and
designs
Personnel – Software architects
v. Implementation/Coding/Development – Translating the designs into
program instructions or coding.
Personnel – Programmers / Developers
vi. Testing – Checking the system to see if it satisfies user
requirements
Personnel – System Testers
vii. Deployment – Installing the system in the user’s environment
so that they may start using it.
Personnel - Developers viii.
Support – Making corrections for remaining errors, or new user
requirements to a system already in use, it is on-going.
Personnel – Maintenance team / developers / Support experts ix.
Documentation – Documenting each task in the project
Personnel – All team members document their respective tasks
Answers:
i. The decimal value is copied into an integer in the first statement, thereby discarding
the fractional component and taking the integral values only which are the same i.e.
6 - (2 marks for the correct answer)
ii. Double num = 20 / 3; - (1 mark for the correct answer)
iii. Implicit – performed by the compiler they is data loss
(1 mark)
Explicit – performed by the developer to avoid data loss. - (1 mark)
Question 4
a) Identify and explain any five (5) access modifiers supported in visual studio.
[10 Marks]
Answer:
- Private – Access is restricted to members of the current scope, method or class
- Public - Access is granted for all members in the same project
- Protected – Access is restricted to the members of the same Namespace
- Friend - Access is restricted to members of the same class
- Protected Friend – Combines features for protected and friend to determine member
access.
- 2 marks for each correct answer, max 10
c) Write three overloaded methods called CalculateArea to calculate the area of a Circle,
Rectangle, and Triangle. ( for Circle π=22/7 ) [9 Marks] Answer:
(3 marks for each correct method, max 9)
//area of rectangle
public
double CalculateArea(double L, double W)
{
return L * W;
}
//area of triangle
//add 3rd parameter isTriangle to differentiate from Rectangle
public
double CalculateArea(double B, double H, bool isTriangle)
{
return 1 / 2 * B * H;
}
//area of circle
public
double CalculateArea(double R)
{
return 22 / 7 * R * R;
}
Question 5
d) Write a program that will allow a system user to enter a Net Income and computes the
amount of income tax as follows: No tax on income up to P15 000; 5 % on income over
P15 000. The program should also display the net income as well as the tax bill.
[10 marks]
double net_income;
double tax_bill;
Console.WriteLine(" Enter net income");
net_income =Convert.ToDouble(Console.ReadLine());
if (net_income <= 15000) { tax_bill = 0;
}
else
{
tax_bill = (0.05 * (net_income - 15000));
}
Console.WriteLine("Net Income"+ net_income);
Console.WriteLine("Tax Bill"+tax_bill);
- Mark allocation:
1 mark variable declaration
2 marks user input
1 mark for calculation of the tax bill
2 displaying Net Income and Tax Bill
5 marks for the if statement construct