Software Development 0708
National College of Ireland Higher Certificate in Computing Applications & Support, Year 1 -HCC Semester Two Examinations – 2007/2008 Monday 28th April 2008 2.00pm – 4.00pm ______________________________________________________________________ Software Development 2 Ms. Elizabeth Sherry Ms. Orla Lahart Answer Section A and One Question form Section B Duration of exam: 2 Hours Attachments: Appendix A and B Page 1 of 6 National College of IrelandSection A (60 marks) Question 1 a) Write a loop that displays all even numbers between 0 and 10 inclusive. b) Write a code segment that accepts a string from the user and displays the length of the string. c) Define the term array. Give an example where one might be used. Declare and create an array of integers. Initialise each element of the array to 0. d) Develop a method which takes a String as a parameter. The method reverses the string and the resultant string is returned. e) Appendix A contains a number of patterns. Which of the patterns would be displayed when the following code is executed? for(int i=0; i<6; i=i+1) { for(int j=0; j<5; j=j+1) { System.out.print("* "); } System.out.println(); } f) Develop a method, which takes a lowercase string as a parameter. The method replaces each vowel in that string with a corresponding numeric value (a is 1, b is 2, c is 3 d is 4 and e is 5). The resultant string should be returned from the method. (6 * 10 marks) Page 2 of 6 National College of IrelandSection B (40 marks) Answer either Question 2 or Question 3. Question 2 a) Develop a loop that displays the following when executed. 0 10 20 30 40 50 b) Develop a method that returns the average value of an array of integers. c) What is the output when the code listed in Appendix B is executed? d) Develop a method which takes a string as a parameter and determines if it is a palindrome. A palindrome is a word that is spelt the same forwards and backwards e.g. mum, dad, navan, deed. The method should return “yes” if it is a palindrome and “no” if it is not a palindrome. (4 * 10 marks) Page 3 of 6 National College of IrelandQuestion 3 a) Write a code segment which validates user input to ensure a user enters a number between 1 and 100 inclusive. b) A one-dimensional array is used to store monthly rainfall. Write a code segment to calculate the average rainfall. c) Write code to determine the maximum value in an array of integers. d) Develop a method that accepts two parameters, a string and a character. The method should calculate the number of times the character occurs in the string. (4 * 10 marks) Page 4 of 6 National College of IrelandAppendix A (a) * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * (b) * * * * * * (c) * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * (d) * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Page 5 of 6 National College of IrelandAppendix B class ExamHCC1Q2c { public static void main(String args[]) { int arr[]; arr = new int[10]; for(int i=0; i
Presentation Transcript
Your Facebook Friends on WizIQ