



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




(NFQ – Level 6)
Section A: This question must be answered.
Section B: Choose 1 question
Section C: Choose 1 question
Examiners: Ms. Deirdre Dunlea Mr. James Greenslade
1 (a) Write a program that will allow a teacher to input examination marks at a keyboard for 20 students. Once all examinations marks have been entered into the computer, she must display the mark and grade for each of the 20 students.
Example: “Student 1 received a mark of 60 and a pass grade” “Student 2 received a mark of 72 and a merit grade”
The grade distribution is shown in the following table:
Mark range Grade 100-85 distinction 84 - 65 merit 64 – 40 pass 39-0 fail
Note: An ARRAY must be used to hold the 20 student results. Use worker methods where necessary [25 marks]
(b) Write a program that reads in three numbers and finds and prints the smallest and largest number. [10 marks]
(c) Write an application using an int and String variable, a while loop and an if test to output the following song to the screen:
99 bottles of beer on the wall 99 bottles of beer Take one down Pass it around
98 bottles of bottles of beer on the wall
Note: when you reach 1 it is only 1 bottle …. The final line is “No more bottles of beer on the wall” [15 marks]
2 (a) Name the three loops in Java and explain in detail how they work? [10 marks]
(b) Declare and initialise an array with the following elements 1,2,3,4,5. [3 marks]
(c) Look at the short Java program listed below. One block of the program is missing. Your challenge is to match the candidate block of code (on the left), with the output that you’d see if the block were inserted. Not all the lines of output will be used, and some of the lines of output might be used more than once. Draw lines connection the candidate blocks of code with their matching command-line output [12 marks]
class Test { public static void main(String [] args) { int x = 0; int y = 0; while(x<5) { ==+++====+++=== BLOCK HERE =====+++===+++ System.out.print(x + ““ + y + “ “); x = x + 1; } } }
class Exercise1b { public static void main(String [] args) { int x = 1; while (x < 10) { if (x > 3) { System.out.println(“big x”);
public static void main(String [] args) { int x = 5; while (x > 1) { x = x- if (x < 3) { System.out.println(“small x”); } }
}
class Exercise1b { int x = 5; while (x > 1) { x = x –1; if (x < 3) { System.out.println(“small x”); } } }
4 (a) Write the code for the following class. [15 marks]
4 (b) Write a main application that creates two students – the first student uses the first constructor and the second uses the second constructor. Now complete the details for both as indicated below: [10 marks]
Student A Student B 3456T 45688H Mary Murphy Luke O’ Brien Maths = 59 66 English = 89 45 Science = 55 78
Now output the average mark for each student and then print out their details to the screen.
Student
studentNumber: String studentName : String mathsMark : int englishMark : int scienceMark : int
Student() Student(String, String) getName( ): String getMathMark(): int setName(String) setNumber(String) setMathMark(int) setEnglishMark(int) setScienceMark(int) enterMarks(int, int, int) calculateAverageMark() print()