Showing posts with label 11/12 SEM 1 BCS2233. Show all posts
Showing posts with label 11/12 SEM 1 BCS2233. Show all posts

9/25/2011

BCS2233 OOP Contoh Test 1



Chapter : 1 to 5
Date : 4/10/2011
Time : 8:30 am (L22)
[ OPEN BOOK (only Liang's slide / book) ]





1. What is debugging? [3 marks]

2. What is the difference between a constant and a variable? [3 marks]

3. What is Overloading Methods? [3 marks]

4. Which of the following are invalid identifiers, why? [8 marks]

a) one
b) hello
c) my Window
d) JAVA
e) 1234
f) hello,there
g) acct122
h) DecafeLattePlease


5. Evaluate the following expressions: [4 marks]

a) 3 + 5 / 7
b) 3 * 3 + 3 % 2
c) 3 + 2 / 5 + -2 * 4
d) 2 * (1 + -(3/4) / 2) * (2 - 6 % 3)


6. Evaluate the following boolean expressions. Assume x, y, and z have some numerical values.
[3 marks]

a) 4 < 5 || 6 == 6
b) 2 < 4 && (false || 5 <= 4)
c) !(z != z)

7. Write a while statement to add numbers 11 through 20. [5 marks]

8. Write a while statement to continuously read in real numbers and stop when a negative number is entered. [5 marks]

9. For each of the following loop statements, determine the value of sum after the loop is executed. [6 marks]

a. int count = 0, sum = 0;
while ( count < 10 ) {
sum += count;
count++;
}


b. int count = 1, sum = 0;
while ( count <= 30 ) {
sum += count;
count += 3;
}


c. int count = 0, sum = 0;
while ( count < 20 ) {
sum += 3*count;
count += 2;
}

10. Write a do–while loop to compute the sum of the first 30 positive odd integers. [5 marks]

11. Write a for loop to compute. [9 marks]

a. the sum of 1, 2, . . . , 100.
b. the sum of 2, 4, . . . , 500.
c. the product of 5, 10, . . . , 50.


12. Write method headers for the following methods: [6 marks]
a. Computing a CPA, given the Number of Credit and the Total Points.
b. Printing the calendar for a year, given the year.
c. Computing a square root.
d. Testing whether a number is odd, and returning true if it is.
e. Printing a message a specified number of times.
f. Computing the monthly payment, given the loan amount, number of years, and annual interest rate.




OOP( LATIHAN CHAPTER 5)

Write method headers for the following methods:

• Computing average, given 2 integers.
CONTOH JAWAPAN : public static double avg(int N1, int N2)
• Find maximum, given 3 integers.
• Computing a sales commission, given the sales amount and the commission rate.
• Printing the calendar for a month, given the month and year.
• Computing a square root.
• Testing whether a number is even, and returning true if it is.
• Printing a message a specified number of times.
• Computing the monthly payment, given the loan amount, number of years, and annual interest rate.
• Finding the corresponding uppercase letter, given a lowercase letter.

9/17/2011

BCS2233 18/9/ 2011 Lab OOP LOOPING



Review Questions




1. How many times is the following loop body repeated? What is the printout of the loop?

a)
int i=1;
while(i>10)
if((i++) % 2 ==0)
system.out.println(i);

b)
int i=1;
while(i10)
if((i++) % 2 ==0)
system.out.println(i);


2. What are the differences between a while loop and a do-while loop?

3. Do the following two loops result in the same value in sum?
a)
for( int i = 0; i<10;++i) {
sum += i;
}

b)
for( int i = 0; i<10;i++) {
sum += i;
}

4. What are the three parts of a for loop control? Write a for loop that prints the numbers from 1 to 100.

5.What does the following statement do?
for ( ; ; ) {   do something; }
6. If a variable is declared in the for loop control, can it be used after the loop exits?
7. Can you convert a for loop to a while loop? List the advantages of using for loops.
8. Convert the following for loop statement to a while loop and to a do-while loop:

long sum = 0;
for (int i = 0; i <= 1000; i++)
sum = sum + i;

Programming Exercises
1* (Repeating additions)
Listing 4.1, SubtractionTutorLoop.java, generates ten random subtraction questions.
Revise the program to generate ten random addition questions for two integers between 1 and 15.
Display the number of correct answers and test time.

2* (Counting positive and negative numbers and computing the average of numbers)
Write a program that reads an unspecified number of integers,
determines how many positive and negative values have been read, and computes the total and
average of the input values, not counting zeros. Your program ends with the input 0.
Display the average as a floating-point number. (For example, if you entered 1, 2, and 0, the average should be 1.5.)

8/01/2011

BCS2233 Object Oriented Programming

Pelajar Bachelor of Computer Science (computer network and Security) akan mengambil subjek Object Oriented Programming (di sebut OOP).





Berikut adalah bahan-bahan pengajaran bagi subjek berkenaan:-

1) 'Lesson Plan' / Rancangan Pengajaran (download)

2) Buku Rujukan Y. Daniel Liang, Introduction to Java™ Programming, Brief Version, 8 Edition. 2011. Pearson Education. Buku ini boleh di dapati dengan saya pada harga RM 75. Stok terhad.

3) 'Power point slide' bagi buku di atas boleh di dapati dari link di bawah:-


Chapter 1 Introduction to Computers, Programs, and Java (download)
Chapter 2 Elementary Programming (download)
Chapter 3 Selections (download)
Chapter 4 Loops (download)
Chapter 5 Methods (download)
Chapter 6 Arrays (download)
Chapter 7 Multidimensional Arrays (download)
Chapter 8 Objects and Classes (download)
Chapter 9 Strings and Text I/O (download)
Chapter 10 Thinking in Objects (download)
Chapter 11 Inheritance and Polymorphism (download)
Chapter 12 GUI Basics (download)
Chapter 13 Exception Handling (download)

4. Perisian
JDK , Jcreator

Bagi membangunkan aplikasi java dalam pc masing2. Pelajar perlu melakukan 'installation' java, dan perkara dibawah perlu di lakukan:-


1. Install JDK. http://java.sun.com/javase/downloads/index.jsp













2. Install JCreator (salah satu IDE utk java). http://www.jcreator.org/download.htm







Tutorial untuk java boleh di dapati dari link di bawah.
http://download.oracle.com/docs/cd/E17409_01/javase/tutorial/index.html

Cara download Installer windows 10 dalam format ISO

1. Jika anda bercadang untuk download windows 10 melalui website rasmi windows - pilihan untuk download dalam format ISO tidak di berikan.  ...