Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

The Independent Institute of Education 2015

MODULE NAME: MODULE CODE:


PROGRAMMING 1B PROG6112

ASSESSMENT TYPE: EXAMINATION (PAPER ONLY)


TOTAL MARK ALLOCATION: 120 MARKS
TOTAL HOURS: 3 HOURS (+15 minutes reading time)
STUDENT NAME:
STUDENT NUMBER:
INSTRUCTIONS:
1. Please adhere to all instructions in the assessment booklet.
2. Independent work is required.
3. Five minutes per hour of the assessment to a maximum of 15 minutes is dedicated to reading
time before the start of the assessment. You may make notes on your question paper, but not
in your answer sheet. Calculators may not be used during reading time.
4. You may not leave the assessment venue during reading time, or during the first hour or
during the last 15 minutes of the assessment.
5. Ensure that your name is on all pieces of paper or books that you will be submitting. Submit all
the pages of this assessment’s question paper as well as your answer script.
6. Answer all the questions on the answer sheets or in answer booklets provided. The phrase
‘END OF PAPER’ will appear after the final set question of this assessment.
7. Remember to work at a steady pace so that you are able to complete the assessment within
the allocated time. Use the mark allocation as a guideline as to how much time to spend on
each section.
Additional instructions:
1. This is an OPEN BOOK assessment.
2. Calculators are not allowed
3. Answer All Questions .

© The Independent Institute of Education (Pty) Ltd 2015


Page 1 of 9
The Independent Institute of Education 2015

General Requirements (Marks: 10)


Writing maintainable code in industry is vital, therefore, you are generally required to:
 Follow good programming practices:
o Variable types correct;
o Variable scope correct; and
o Class and method naming standards correct.
 Insert comments to show logic and design for the support of code maintainability;
 Code efficiently. Redundant code must be avoided.

Spend 15 minutes ensuring that your programs meet the general criteria below (10).

Requirement Maximum Examiners Moderators


Mark Mark Mark
Good Programming Practice:
 Not followed at all = 0 marks;
 Average - Minor changes required = 1—2 (3)
marks;
 Excellent – No changes required = 3.
Code Efficiency:
 Poor – much code is duplicated = 0 marks;
 Average – some redundant code exists = 1 (2)
mark;
 Excellent – code very maintainable = 2 marks.
Comment Statements:
 Poor – No comments = 0 marks;
 Average – Some Comments = 1—2 marks; (3)
 Excellent – all necessary comments given to
show logic = 3 marks.
Program(s) compile and execute:
 No – Many changes required = 0 marks;
(2)
 Average – Minor changes required = 1 mark;
 Yes – No changes required = 2 marks.
Total (10)

© The Independent Institute of Education (Pty) Ltd 2015


Page 2 of 9
The Independent Institute of Education 2015

Question 1 (Marks: 45)


Create an abstract class named Product which has a String field for the name of the product and a
double field for the price of the product. Within this class create a constructor that requires the
product name and add two (2) get() methods to return the product name and the price of the
product. Include an abstract method named setPrice().

Create two (2) child classes of Product called Perishable and NonPerishable. Each must include the
setPrice() method that will set the price for a Perishable product to R11.99 and R19.99 for a
NonPerishable product. Write a constructor for each child class and include a call to the setPrice()
method within each.

Create a class named UseProduct to demonstrate using an object of each child class and print out
the following:

Save your files as Product.java, Perishable.java, NonPerishable.java and UseProduct.java.

© The Independent Institute of Education (Pty) Ltd 2015


Page 3 of 9
The Independent Institute of Education 2015

Marking Guideline Mark Examiner Moderator


Abstract class with fields, methods and abstract method:
 Not created – 0 marks;
 Incomplete/ incorrect – up to a maximum of 12 (15)
marks;
 Correct – 15 marks.
First subclass with constructor, set method:
 Not created – 0 marks;
 Incomplete/incorrect – up to a maximum of 8 (10)
marks;
 Correct – 10 marks.
Second subclass with constructor, set method:
 Not created – 0 marks;
 Incomplete/ incorrect – up to a maximum of 8 (10)
marks;
 Correct – 10 marks.
Use class: Objects instantiated, get methods called:
 Not created – 0 marks;
 Incomplete/ incorrect – up to a maximum of 6 (7)
marks;
 Correct – 8 marks.
Output shown (2)
Saved correctly (1)
Total (45)

© The Independent Institute of Education (Pty) Ltd 2015


Page 4 of 9
The Independent Institute of Education 2015

Question 2 (Marks: 50)


Time Allocation: 90 minutes.
Your local Campus Canteen requests you to write a Java program that will store and process food
orders for the canteen. They currently write all this information on paper.

Write a java program that uses methods/ procedures and parameter passing to do the following:
Q.2.1 When the program starts it must display the following GUI:

These are the menu structures:

Note that the Save Order Menu item is disabled on startup.

© The Independent Institute of Education (Pty) Ltd 2015


Page 5 of 9
The Independent Institute of Education 2015

Q.2.2 When the user clicks on the Place Order Menu item, read the user choices and store
these in variables. Then display this information in a message box as shown below.

Q.2.3 When the user clicks on the Amount Due menu item, use the following price
information to calculate the total amount due for the order and display in a
message box as shown below:

The prices for canteen items are as follows:


ITEM PRICE
Chicken Salad R20
Club Sandwich R17
Burger R28
Vegetable Wrap R12
Pie R15
Milkshake R17
Fresh Juice R7
Cold drink R12
Tea R10
Coffee R10

© The Independent Institute of Education (Pty) Ltd 2015


Page 6 of 9
The Independent Institute of Education 2015

Water is free and special requests are also free.

Q.2.4 When the user clicks on the Print Order menu item, print the report as per the
screenshot below in a textarea/ listbox:

Q.2.5 When the user clicks on Save Order, write the entire order to a new file named
“NewOrder.txt”. Also show a message confirmation box as displayed below:

© The Independent Institute of Education (Pty) Ltd 2015


Page 7 of 9
The Independent Institute of Education 2015

Q.2.6 The exit menu item must display a messagebox which must be appropriately coded,
as follows:

Save your file as Question2.java.

Q.2.7
Marking Guideline Mark Examiner Moderator
Import statements 2
Variable and array declarations 3
GUI Design 10
Menu structure 3
Message Boxes 2
Open File-Place and show order 5
Calculate Amount Due menu code 10
Print Order Menu code 5
Save Order – write to new file 8
Text Files created and saved 2
TOTAL 50

© The Independent Institute of Education (Pty) Ltd 2015


Page 8 of 9
The Independent Institute of Education 2015

Question 3 (Marks: 15)


Design an application that extends JFrame and that displays a red unhappy face on the screen. Save
the file as Unhappy.java.

Marking Guideline Mark Examiner Moderator


Created graphic:
 Not created – 0 marks;
 Attempted but not complete/ correct – up to a (12)
maximum of 10 marks;
 Created correctly – 12 marks.
Save file correctly (3)
Total (15)

END OF PAPER

© The Independent Institute of Education (Pty) Ltd 2015


Page 9 of 9

You might also like