Final Examination Semester 3 / Year 2012

Similar documents
Final Examination Semester 3 / Year 2010

Final Examination Semester 3 / Year 2007

Final Examination Semester 2 / Year 2011

Final Examination Semester 3 / Year 2010

Final Examination Semester 3 / Year 2012

Final Examination Semester 2 / Year 2010

Final Examination Semester 3 / Year 2010

Final Examination Semester 3 / Year 2012

Final Examination Semester 2 / Year 2011

Final Examination Semester 2 / Year 2010

M105: Introduction to Programming with Java Midterm Examination (MTA) Makeup Spring 2013 / 2014

Midterm Examination (MTA)

Final Examination Semester 2 / Year 2010

Final Examination Semester 2 / Year 2012

Full file at

Final Examination Semester 2 / Year 2012

Lecture 5: Methods CS2301

Final Examination Semester 3 / Year 2008

Exam 2. Programming I (CPCS 202) Instructor: M. G. Abbas Malik. Total Marks: 40 Obtained Marks:

Question: Total Points: Score:

EXAMINATION FOR THE BSC (HONS) INFORMATION TECHNOLOGY; BSC (HONS) INFORMATION SYSTEMS & BSC (HONS) COMPUTER SCIENCE; YEAR 1

Sequence structure. The computer executes java statements one after the other in the order in which they are written. Total = total +grade;

CS-201 Introduction to Programming with Java

Selected Questions from by Nageshwara Rao

COMP-202B - Introduction to Computing I (Winter 2011) - All Sections Example Questions for In-Class Quiz

AP Computer Science Unit 1. Programs

CS111: PROGRAMMING LANGUAGE II

b. Suppose you enter input from the console, when you run the program. What is the output?

PROGRAMMING FUNDAMENTALS

INDEX. A SIMPLE JAVA PROGRAM Class Declaration The Main Line. The Line Contains Three Keywords The Output Line

Data and Variables. Data Types Expressions. String Concatenation Variables Declaration Assignment Shorthand operators. Operators Precedence

Mid Term Exam 1. Programming I (CPCS 202) Instructor: M. G. Abbas Malik Date: Sunday November 3, 2013 Total Marks: 50 Obtained Marks:

Introduction to Computer Science Unit 2. Notes

COMP 250: Java Programming I. Carlos G. Oliver, Jérôme Waldispühl January 17-18, 2018 Slides adapted from M. Blanchette

COE 211/COE 212 Computer/Engineering Programming. Welcome to Exam II Thursday December 20, 2012

SAMPLE QUESTIONS FOR DIPLOMA IN INFORMATION TECHNOLOGY; YEAR 1

1. Which of the following is the correct expression of character 4? a. 4 b. "4" c. '\0004' d. '4'

UNIVERSITI SAINS MALAYSIA. CIT502 Object-Oriented Programming and Software Engineering

1 Short Answer (10 Points Each)

CS 231 Data Structures and Algorithms Fall Event Based Programming Lecture 06 - September 17, Prof. Zadia Codabux

Announcements. PS 3 is due Thursday, 10/6. Midterm Exam 1: 10/14 (Fri), 9:00am-10:53am

Full file at

C212 Early Evaluation Exam Mon Feb Name: Please provide brief (common sense) justifications with your answers below.

Java Tutorial. Saarland University. Ashkan Taslimi. Tutorial 3 September 6, 2011

Some Sample AP Computer Science A Questions - Solutions

CSE 20. SAMPLE FINAL Version A Time: 180 minutes. The following precedence table is provided for your use:

CS 170 Section 3, Spring 2015 Programming in Java Midterm Exam 1. Name (print):

Example: Monte Carlo Simulation 1

JAVA PROGRAMMING LAB. ABSTRACT In this Lab you will learn to define and invoke void and return java methods

(A) 99 ** (B) 100 (C) 101 (D) 100 initial integers plus any additional integers required during program execution

Introduction to Computer Science Unit 2. Notes

McGill University School of Computer Science COMP-202A Introduction to Computing 1

Introduction to OOP with Java. Instructor: AbuKhleif, Mohammad Noor Sep 2017

CPSC 219 Extra review and solutions

Date: Dr. Essam Halim

Chapter 2: Using Data

CSEN202: Introduction to Computer Science Spring Semester 2017 Midterm Exam

CS111: PROGRAMMING LANGUAGE II

Exam 1. Programming I (CPCS 202) Instructor: M. G. Abbas Malik. Total Marks: 45 Obtained Marks:

Problem Grade Total

Java Classes: Random, Character A C S L E C T U R E 6

Conditional Execution

Building Java Programs

Give one example where you might wish to use a three dimensional array

Faculty of Science Midterm. COMP-202B - Introduction to Computing I (Winter 2008)

Building Java Programs

Full download all chapters instantly please go to Solutions Manual, Test Bank site: testbanklive.com

AP CS Unit 3: Control Structures Notes

Arrays. Eng. Mohammed Abdualal

(A) 99 (B) 100 (C) 101 (D) 100 initial integers plus any additional integers required during program execution

I pledge by honor that I will not discuss this exam with anyone until my instructor reviews the exam in the class.

Programming Exercise 7: Static Methods

Chapter 02: Using Data

Course Outline. Introduction to java

Web-CAT submission URL: CAT.woa/wa/assignments/eclipse

Chapter 2: Review Exercise Solutions R2.1

Primitive Data, Variables, and Expressions; Simple Conditional Execution

CS 106 Introduction to Computer Science I

Final Examination Semester 1 / Year 2011

Computer Programming, I. Laboratory Manual. Experiment #3. Selections

Java Foundations: Introduction to Program Design & Data Structures, 4e John Lewis, Peter DePasquale, Joseph Chase Test Bank: Chapter 2

Page 1 of 16. Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Example. Write a program which sums two random integers and lets the user repeatedly enter a new answer until it is correct.

Variables, Types, Operations on Numbers

CS141 Programming Assignment #6

Jump Statements. The keyword break and continue are often used in repetition structures to provide additional controls.

CS 170 Section 3, Spring 2015 Programming in Java Midterm Exam 1. Name (print):

AL GHURAIR UNIVERSITY College of Computing. Objectives: Examples: Text-printing program. CSC 209 JAVA I

Administration. Conditional Statements. Agenda. Syntax. Flow of control. Lab 2 due now on floppy Lab 3 due tomorrow via FTP

Jump Statements. The keyword break and continue are often used in repetition structures to provide additional controls.

Lecture #6-7 Methods

Check out how to use the random number generator (introduced in section 4.11 of the text) to get a number between 1 and 6 to create the simulation.

Write a program which converts all lowercase letter in a sentence to uppercase.

COE 212 Engineering Programming. Welcome to Exam I Thursday June 21, Instructor: Dr. Wissam F. Fawaz

Section 004 Spring CS 170 Exam 1. Name (print): Instructions:

LAB 11: METHODS. CPCS The Lab Note Lab 11 Page 1. Statement Purpose:

Opening Problem. Find the sum of integers from 1 to 10, from 20 to 30, and from 35 to 45, respectively.

1. An operation in which an overall value is computed incrementally, often using a loop.

Birkbeck (University of London) Software and Programming 1 In-class Test Mar 2018

Controls Structure for Repetition

Transcription:

Final Examination Semester 3 / Year 2012 COURSE : INTRODUCTION TO PROGRAMMING COURSE CODE : PROG1013 TIME : 2 1/2 HOURS DEPARTMENT : COMPUTER SCIENCE LECTURER : LIM PEI GEOK Student s ID : Batch No. : Notes to candidates: 1) The question paper consists of 6 pages includes this page. Section A: 10 questions (20 marks) Section B: 4 questions (20 marks) Section C: 3 questions (60 marks) 2) Answer all questions. 3) Write your answer for Section A and Section B in answer booklet. 4) Save your answer for question in Section C and submit your answer in softcopy to Southern College E-Learning System.

SECTION A: MULTIPLE CHOICE QUESTION (10 X 2 = 20 MARKS) Please choose most appropriate answer. State the answer in the answer booklet. 1. Which of the following is INVALID statement to cast a variable to another data type? a. int x = (int) ABC b. int x = (int) 10.5 c. double x = (double)10 d. char x = (char) 65 2. Which of the following expressions explain Math.pow(a,5)? a. 5 a b. a 5 c. a*5 d. 3. Which of the following operator is used to ensure that the two conditions must be true to return a true result? a. && b. c. ^^ d. ^ 4. int sum = 0, x = 0; while(x<10){ if(x > 5 && x < 9) x = x + 1; else x = x + 2; sum += x; System.out.println(sum); Consider the codes above. What is the value of sum variable? a. 10 b. 12 c. 17 d. 18 5. Which of the following is NOT Java keyword? a. class b. double c. scanner d. final 6. What is num after evaluation? int num = 10; num = (true ^ false)? 1: 2; a. 11 b. 1 c. 12 d. 2 1/5

7. A program contains a method with the header: public static double calculatesalary(double amount, String name) Which of the following methods can coexist in the same program with no possible ambiguity? a. public static double calculatesalary(double annualamount, String taxpayerid) b. public static String calculatesalary(double amount, String taxpayername) c. public static double calculatesalary(string name, double amount) d. All of these can coexist without ambiguity. 8. Which of the following is true about methods? a. A program can call one method at most. b. A program can contain a method that calls another method. c. A method can contain one or more other method. d. All of these are true. 9. Each element in a five-element array can hold value(s)? a. one b. five c. at least five d. an unlimited number of 10. Consider the following statement, int[] number = {0,0,0,0; Which of the following expression is VALID? a. number[2] = 10 b. int length = number.length c. number[1] = number[0] + 2 d. All of the above 2/5

SECTION B: SHORT QUESTIONS (20 MARKS) Question 1 (5 Marks) Convert the following for loop into while loop. int x; for(x=0; x<50; x+=5){ System.out.println(x); Question 2 (5 Marks) Convert the multiple if-else statements to switch case. char grade = A ; if(grade == A grade == B ){ System.out.println( Passed ); else if (grade == C ){ System.out.println( Failed ); else{ System.out.println( Invalid input ); Question 3 (5 Marks) There is one error in the following code fragment. Identified the error and correct it. 1 public class Test{ 2 public static void main(string[] args){ 3 final double number = 10; 4 number = 11.5; 5 6 Question 4 (5 Marks) Show the output for the following program. public class DisplayOutput{ public static void main (String[] args) { int x = 10; int y = addvalue(x); System.out.println("x = "+x+"; y = "+y); public static int addvalue(int z){ return (++z); 3/5

SECTION C: CODING QUESTIONS (60 MARKS) Submit your answer in softcopy and upload it to Southern E-Learning System. Question 1 (25 Marks) Ahmad is a carpenter who wants an application to compute the price of any desk a customer orders based on the following: desk length and width in inches, type of wood and number of drawers. The price is compute as follows: The minimum charge for all desks is RM 200. If the surface (length * width) is over 750 square inches, add RM 50. If the wood is mahogany, add RM 150; for oak, add RM 125. No charge is added for pine. For every drawer in the desk, there is an additional RM 30 charge. Write a program to accept data for customer name, length and width of the desk ordered, type of wood, and number of drawers. Your program is then display the all the entered data and the final price for the desk. Sample output: Welcome to Ahmad Furniture Company Please enter your order here! Enter your name: Christine Enter the length of desk (inches): 100 Enter the width of desk (inches): 100 Enter the type of wood (1:Mahogany 2:Osk 3:Pine): 2 Enter the number of drawers: 2 Customer name: Christine Information of Desk: Length: 100.0 Width: 100.0 Type of wood: Osk Number of drawer: 2 Price: RM435.0 Thanks You! Question 2 (18 Marks) Write a java program to ask user to enter 10 numbers. The number should between the ranges 0 to 100. If the user enters a number that out of the range then your program should ask user to enter a number again. All the valid number should store into an array called numberlist. Your program should able to display the number in reverse order. 4/5

Sample output: Enter number 1: 10 Enter number 2: 20 Enter number 3: 300 Enter number 3: 30 Enter number 4: 40 Enter number 5: 50 Enter number 6: 60 Enter number 7: 70 Enter number 8: 80 Enter number 9: 90 Enter number 10: 100 Display the numberlist in reverse order: 100 90 80 70 60 50 40 30 20 10 INTRODUCTION TO PROGRAMMING Question 3(17 Marks) Write a java program that calculates the volume of a sphere. Your program will prompt user to enter radius of the sphere. Write a method that returns the volume of the sphere using the following method header: public static double calculatevolume (double r) The formula for computing the volume is Your program will then display the volume. The value of radius and volume should be format to two decimal digits after the decimal point. Sample output: Enter radius : 5 Radius : 5.00 Volume : 392.70 000 5/5