Вы находитесь на странице: 1из 8
INTI International College Subang LAUREATE INTERNATIONAL UNIVERSITIES FINAL Examination Paper (COVER PAGE) Session : _August 2014 a = Programme : Diploma In Information And Communication Technology _@ICTN/DICTIDNS)), _ Course : ICT2100/CSC2100/2114 Object-Oriented Programming /JAVA Programming Date of Examination + December 8, 2014 _ _ Time _5:00pm~ 7:00pm Reading Time: Nil faa Duration : 2 Hours Special Instructions Answer any FOUR (4) questions in the answer booklet provided. Materials permitted = Non- Programmable Calculator _ Materials provided Nil _ Examiner (s) : _Ms. Ng Ruoh Ling, Koo Lee Chun. _ _ Moderator : _Ms. Noor Hasrina This paper consists of 8 printed pages, including the cover page. ICT2100/CSC2100/2114 (F) / Page 1 of 7 INTI INTERNATIONAL COLLEGE SUBANG DIPLOMA IN INFORMATION AND COMMUNICATION TECHNOLOGY (DICTN/DICTIDNSI) ICT2100 / CSC2100/2114 : OBJECT-ORIENTED PROGRAMMINGNAVA PROGRAMMING FINAL EXAMINATION: AUGUST 2014 SESSION Instructions: This paper consists of SIX (6) questions. Answer any FOUR (4) questions in the answer booklet provided. All questions carry equal marks. ‘Question 1 (@) The parking rate in a shopping mall is RM3 for the first 2 hours, RMI.50 for the subsequent hour. The maximum charge per day is RM20. Write a simple program that reads the number of hours parked (in integer) in a day and display the parking charges. (8 marks) (b) Write a program that will randomly generate two positive one-digit integers (1 to 9) and display them as a multiplication question to the user. If the answer given by the user is correct, display the message “Correct”. Else display the message “Wrong”. Run the multiplication test for 10 times and display the score (over 100) of the user. Below is the sample of the program: How much is 3 times 4? 12 Correct How much is 8 times 5? 40 Correct How much is 7 times 6? 40 Wrong Your score is 80/100 (@ marks) (© Write a valid statement for the following: (i) Convert the first character in a String variable named firstname to a character and assign it to a char variable named initi (i) Read a value from the user using dialog box and assign it to a double variable named amount. (ii) Declare an int constant named MAXIMUM and assign the value of 100 to it, (iv) Declare a String array named days and initialize all the 7 days (Sunday, Monday, ‘Tuesday until Saturday) in a week to the array in one statement. (8 marks) ICT2100/CSC2100/2114 (B) / Page 2 of 7 ‘Question 2 (a) Identify the errors for the following codes. Modify the code to fix the error. (Hint: each sub-question contains ONE error.) () public class Program { public static void main(String [ ] args) ( Display( ); ) public void Display( }{ System. out.print1n("Hello' } (i) int a = JoptionPane.showInputDialog ("Enter a nunbe int b=a* a; System.out.pritnin ("square of "tat ="4b) 7 Gi) System.out.printin (i); }while (i <=5); (iv) Scanner s=new Scanner (System. in); String b=s.next (); switch (b) { case 'a':System.out.printin("first choice") ;break; case 'b!:System.out-print1n("second choice") ;break; ) (¥) Scanner console = new Scanner (System.in); int a = console.nextint (); double b = console.nextDouble() if (a>10) bratby System.out.printin (a); else System.out-printin (a); (vi) public int Display() { System.out.println ("Hello"); ) (12 marks) (>) Given the formula below: ft 2 zex't3]—> | - vx Ea Write a method that will take the positive value of x in int type and return the result of z in double type. (Smarks)

Вам также может понравиться