Java Programming Exam for Higher Certificate in Computing (Autumn 2008), Exams of Software Development Methodologies

The instructions and questions for an exam in java programming for students enrolled in the higher certificate in science in computing in information technology program at cork institute of technology. The exam covers topics such as java programming, linked lists, binary trees, and file i/o. Students are required to write java code to solve various programming problems, including writing a java program to calculate salesperson salaries, adding nodes to a linked list, shuffling elements in a linked list, inserting nodes into a binary tree, and reading student records from a file.

Typology: Exams

2012/2013

Uploaded on 03/25/2013

digvijay
digvijay 🇮🇳

4.4

(17)

185 documents

1 / 7

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Cork Institute of Technology
Higher Certificate in Science in Computing in Information Technology
Support – Award
(KITSU_6_Y2)
Autumn 2008
Software Development
(Time: 2 ½ Hours)
Instructions
Answer Question 1 and any two other
questions.
Examiners: Mr. J. Greenslade
Mr. J. Walsh
Mr. J. Doyle
Q.1 A company pays their sales staff a basic pay of €200 per week plus a
commission of 4 % of their sales for that week. E.g. if a salesperson sold
€5000 of goods in a week, their salary would be €400 (€200 base pay and
€200 commission).
a) Write a Java program that accepts the sales of each employee in turn and
displays the
salary for that individual.
The Program should stop when -1 is input for sales.
Use any method of input and output you like. You do not have to cater for
the case where a user does not enter data correctly.
(25 marks)
b) Modify the program in part (a) so that it prints the average sales for the
entire sales force. That is the total of all sales divided by the number of
sales that were input. Use an if-statement to avoid division by zero.
(5 marks)
pf3
pf4
pf5

Partial preview of the text

Download Java Programming Exam for Higher Certificate in Computing (Autumn 2008) and more Exams Software Development Methodologies in PDF only on Docsity!

Cork Institute of Technology

Higher Certificate in Science in Computing in Information Technology

Support – Award

(KITSU_6_Y2)

Autumn 2008

Software Development

(Time: 2 ½ Hours)

Instructions Answer Question 1 and any two other questions.

Examiners: Mr. J. Greenslade Mr. J. Walsh Mr. J. Doyle

Q.1 A company pays their sales staff a basic pay of €200 per week plus a commission of 4 % of their sales for that week. E.g. if a salesperson sold €5000 of goods in a week, their salary would be €400 ( €200 base pay and €200 commission ).

a) Write a Java program that accepts the sales of each employee in turn and displays the salary for that individual.

The Program should stop when -1 is input for sales.

Use any method of input and output you like. You do not have to cater for the case where a user does not enter data correctly. (25 marks)

b) Modify the program in part ( a) so that it prints the average sales for the entire sales force. That is the total of all sales divided by the number of sales that were input. Use an if-statement to avoid division by zero. (5 marks)

Q.2 Use the code for Node and MyLinkedList from APPENDIX I for this question.

a) Here is a diagram of the first Node being added to a linked list:-

Fig. 1 A linked list with the first node being added.

Draw a similar diagram showing the third Node being added. Label each Node with A B or C. You may choose to show adding at the front or back. (5 marks)

b) Assume that there is a class attribute java.util.LinkedList called list that is filled with the values from 1 to 1000 in order. Write a method for that class that shuffles the numbers. Make sure that the Integer in each element of list is selected for movement at least once. (20 marks)

c) This part of the question relates to the shuffling process in part (b).

Do you think it would be quicker to copy the Integer values from list to an array before shuffling the array and then copying the Integer values back from the shuffled array to list , than to shuffle list directly? Explain your answer. (10 marks)

Q. 4 There is a file of Student s called “StudentRecords”. The code for Student is in APPENDIX III.

a) Write a complete Java program (class) to display the name of the Student with the largest mark. The lowest mark possible is 0. Assume that Student is available to the class you are writing. (30 marks)

b) Modify the code to display the names of all the Student s who passed. A student passes when their mark is 40 or more. (5 marks)

APPENDIX I

public class MyLinkedList{ private Node first; private Node last;

public MyLinkedList() { first = null; last = null; }

public void addFirst(Object o){ …

public void addLast(Object o){ …

public Object removeFirst(){ …

public Object removeLast(){ …

public boolean isEmpty(){ … }

class Node{ private Object info; private Node next;

//constructor public Node(Object d){ info = d; next = null; }

public void setInfo(Object d){ info = d;

APPENDIX III

class Student implements Serializable { private int mark; private String name;

//constructor public Student(String n, int m) { mark = m; name = n; }

public void setMark(int m) { mark = m; } public void setName(String n) { name = n; } public int getMark() { return mark; } public String getName() { return name; }

}