Terima Kasih.
Showing posts with label 12/13 SEM 1 BCS2233. Show all posts
Showing posts with label 12/13 SEM 1 BCS2233. Show all posts
1/01/2013
Markah Penilian OOP BCBM dan BCNS
Berikut adalah markah-markah penilian OOP. Sebarang kesilapan - mohon maklumkan pada saya.
12/08/2012
BCS2233 OOP : QUIZ 3
Nama:________________________________
Matric:___________________________
Course:_________________________
*hantar sebelum jam 5:00pm 9/12/2012.
Answer any three (3) the following question :-
(Jawap mana-mana tiga (3) dari soalan berikut:-
Matric:___________________________
Course:_________________________
*hantar sebelum jam 5:00pm 9/12/2012.
Answer any three (3) the following question :-
(Jawap mana-mana tiga (3) dari soalan berikut:-
- Describe the relationship between an object and its defining class.
(2 Marks) - Describe Abstraction in object oriented programming.
(2 Marks) - What is exceptions? (2 Marks)
- Explain the difference between a public and a private member of a class.
(2 Marks) - Explain the difference between a constructor and destructor.
(2 Marks) - What is inheritance and why use inheritance? (2 Marks)
12/01/2012
BCS2233 OOP: CREATING CLASS
Write a class for each of the following specifications. In each case, include a constructor that set each member values to 0 and a member method named showdata() that can be used to display member values.
1. A class named TIME that has integer data members named SECS, MINS, and HOURS.
2. A class named TRIANGLE that has integer data members LENGTH and WIDTH.
3. A class named STUDENT that has string data members named NAME, ADDRESS and COURSE and a floating point data member named CPA.
Jawapan untuk soalan 1.
class TIME {
private int SECS, MINS, HOURS;
TIME() {
SECS= MINS= HOURS=0;
}
public showdata() {
System.out.println("Second="+SECS);
System.out.println("Minute="+MINS);
System.out.println("Hour="+HOURS);
}
}
UML untuk class TIME adalah spt berikut:
1. A class named TIME that has integer data members named SECS, MINS, and HOURS.
2. A class named TRIANGLE that has integer data members LENGTH and WIDTH.
3. A class named STUDENT that has string data members named NAME, ADDRESS and COURSE and a floating point data member named CPA.
Jawapan untuk soalan 1.
class TIME {
private int SECS, MINS, HOURS;
TIME() {
SECS= MINS= HOURS=0;
}
public showdata() {
System.out.println("Second="+SECS);
System.out.println("Minute="+MINS);
System.out.println("Hour="+HOURS);
}
}
UML untuk class TIME adalah spt berikut:
11/27/2012
BCS2233 OOP Class and Object
Power point slide untuk :-
Latihan untuk menguji kefahaman pelajar tentang object dan constructor
Tuliskan output untuk program berikut :-
public class TestRec {
public static void main(String[] args) {
Rectangle s4 = new Rectangle();
System.out.println(" Perimeter s4=" + s4.per());
System.out.println("Area s4 =" +s4.area());
Rectangle segi4 = new Rectangle(3,5);
System.out.println(" Perimeter segi4=" + segi4.per());
System.out.println("Area segi4 =" +segi4.area());
}
}
class Rectangle {
double length, width;
double per()
{
return 2*(length+width); }
double area()
{
return length*width; }
Rectangle()
{
width =1;
length =2; }
Rectangle(double newwidth, double newlength)
{
width =newwidth;
length =newlength; }
}
11/24/2012
Class Activities 25 /11/2012
Class Activities 25 /11/2012 . Please submit before 5:00 pm in hard copy form.
Name :______________________
Matric:______________________
Course:_____________________
Please refer to Chapter 8 Objects and Classes (slide 4 to 7) + Google to find the answer for the following questions.
QUESTION 1 (TRUE / FALSE)
i) Object-oriented programming (OOP) involves programming using objects. (T/ F)
ii)An object has both a state(also called properties or data field ) and behavior(also called methods). (T/ F)
QUESTION 2 (SHORT ANSWER)
Consider the following class and answer the questions below:-
i) What is the name of the above class?
ii)List the state of the above class.
iii) List the behavior of the above class.
iv) What is Constructor
11/06/2012
BCS2233 OO Markah Quiz 1 dan Asgmt 1
| No. | Matric No. | Course | Quiz 1 (17) | Asgmt 1 |
| 1 | 12B07101 | BCNS | 22 | |
| 2 | 12B07102 | BCNS | 30 | |
| 3 | 12B07104 | BCNS | 15 | 14 |
| 4 | 12B07106 | BCNS | 39 | |
| 5 | 12B07107 | BCNS | 37 | |
| 6 | 12B07108 | BCNS | 15 | 37 |
| 7 | 12B07109 | BCNS | 15 | 39 |
| 8 | 12B07110 | BCNS | 30 | |
| 9 | 12B07111 | BCNS | 37 | |
| 10 | 12B07112 | BCNS | 15 | 37 |
| 11 | 12B07114 | BCNS | 35 | |
| 12 | 12B07115 | BCNS | 15 | 38 |
| 13 | 12B07116 | BCNS | 14 | 28 |
| 14 | 12B07118 | BCNS | 35 | |
| 15 | 12B07119 | BCNS | 14 | 28 |
| 16 | 12B04108 | BCBM | 15 | 39 |
| 17 | 11B04018 | 13 | 22 |
| No. | Matric No. | Course | quiz1 (17) | Asgmt 1 |
| 1 | 11B04002 | BCBM | 8 | 23 |
| 2 | 11B04003 | BCBM | 8 | 39 |
| 3 | 11B04004 | BCBM | 15 | 36 |
| 4 | 11B04005 | BCBM | 8 | 39 |
| 5 | 11B04006 | BCBM | 8 | 17 |
| 6 | 11B04007 | BCBM | 12 | 23 |
| 7 | 11B04008 | BCBM | 15 | 39 |
| 8 | 11B04009 | BCBM | 12 | 31 |
| 9 | 11B04012 | BCBM | 9 | 27 |
| 10 | 11B04013 | BCBM | 7 | 33 |
| 11 | 11B04016 | BCBM | 8 | 27 |
| 12 | 11B04017 | BCBM | 15 | 31 |
| 13 | 11B04018 | BCBM | 13 | |
| 14 | 11B04022 | BCBM | 7 | 33 |
| 15 | 11B04023 | BCBM | 10 | 30 |
| 16 | 11B04025 | BCBM | 8 | 36 |
| 17 | 11B04105 | BCBM | ||
| 18 | 11B04106 | BCBM | 12 | 30 |
| 19 | 12B04108 | BCBM | 39 |
11/05/2012
BCS 2233 OOP Assignment 2
1. You are required to provide (i) Algorithm
(Flowchart or Pseudocode) and (ii) Java program for each of the following problems.
II. Read 10 integers and find the total of even number and odd number entered.
III. Read 10 integers and find the total of positive number and negative number.
IV. Write a program that prompts the user to enter the number of students and each student's name and score, and finally displays the student with the highest score.
2. Write method headers for the
following methods:
- 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.
Sales
Amount Commission Rate
$0.01–$5,000 8 percent
$5,000.01–$10,000 10 percent
$10,000.01 and above 12 percent
11/03/2012
BCS2233 QUIZ 2 (CHAPTER 4 LOOPS)
QUIZ 2 (CHAPTER 4 LOOPS)
Name:_______________
Matric:______________
Please submit before 5:00 pm 4/11/12.
SECTION A
-
1. There are three types of control statements: sequence, selection, and repetition. (T/F)2.There are three types of repetition statements: the while loop, the do-while loop, and the for loop.(T/F)
-
3. In while loop, if the condition is false, the loop body is executed; if it is true, the loop terminates. (T/F)4. The do-while loop is similar to the while loop, except that the do-while loop executes the loop body first and then checks the loop-continuation-condition to decide whether to continue or to terminate.(T/F)
-
5.The while loop and the do-while loop are often used when the number of repetitions is unspecified.(T/F)6. The for loop control has two parts. The first part is an initial action that often initializes a control variable. The second part, the loop-continuation-condition, determines whether the loop body is to be executed. (T/F)
-
SECTION B
10/16/2012
10/15/2012
BCS2233 OOP TEST 1 TRIAL
latihan individu - tak perlu hantar
Chapter 1
1.1 Define hardware and software.
1.2 Define machine language, assembly language, and high-level programming language.
1.3 What is an operating system?
1.4 What is a comment? What is the syntax for a comment in Java? Is the comment ignored by the compiler?
1.5 Identify and fix the errors in the following code:
1 public class Welcome {
2 public void Main(String[] args) {
3 System.out.println('Welcome to Java!);
4 }
5 }
Chapter 2
2.1 Which of the following are invalid identifiers, why?
a) one
b) hello
c) my Window
d) JAVA
e) 1234
f) hello,there
g) acct122
h) DecafeLattePlease
2.2 Write an "Evaluation Tree" for the following expressions:
a) 3 + 5 / 7
b) 3 * 3 + 3 % 2
c) 3 + 2 / 5 + -2 * 4
d) 2 * (1 + -(3/4) / 2) * (2 - 6 % 3)
2.3 Write an algorithm (flowchart or pseudocode) for the following problem:-
(Converting Fahrenheit to Celsius) Write a program that reads a Fahrenheit degree in double from an input dialog box, then converts it to Celsius and displays the result in a message dialog box. The formula for the conversion is as follows:
celsius = (5/9) * (fahrenheit - 32)
Chapter 3
3.1 Suppose x = 3 and y = 2, show the output, if any, of the following code. What is the output if x = 3 and y = 4? What is the output if x = 2 and y = 2? Draw a flowchart of the following code:
if (x > 2) {
if (y > 2) {
int z = x + y;
System.out.println("z is " + z);
}
}
else
System.out.println("x is " + x);
3.2 Write an algorithm (flowchart or pseudocode) for the following problem:-
(Computing the perimeter of a triangle) Write a program that reads three edges for a triangle and computes the perimeter if the input is valid. Otherwise, display that the input is invalid. The input is valid if the sum of any two edges is greater than the third edge.
Chapter 1
1.1 Define hardware and software.
1.2 Define machine language, assembly language, and high-level programming language.
1.3 What is an operating system?
1.4 What is a comment? What is the syntax for a comment in Java? Is the comment ignored by the compiler?
1.5 Identify and fix the errors in the following code:
1 public class Welcome {
2 public void Main(String[] args) {
3 System.out.println('Welcome to Java!);
4 }
5 }
Chapter 2
2.1 Which of the following are invalid identifiers, why?
a) one
b) hello
c) my Window
d) JAVA
e) 1234
f) hello,there
g) acct122
h) DecafeLattePlease
2.2 Write an "Evaluation Tree" for the following expressions:
a) 3 + 5 / 7
b) 3 * 3 + 3 % 2
c) 3 + 2 / 5 + -2 * 4
d) 2 * (1 + -(3/4) / 2) * (2 - 6 % 3)
2.3 Write an algorithm (flowchart or pseudocode) for the following problem:-
(Converting Fahrenheit to Celsius) Write a program that reads a Fahrenheit degree in double from an input dialog box, then converts it to Celsius and displays the result in a message dialog box. The formula for the conversion is as follows:
celsius = (5/9) * (fahrenheit - 32)
Chapter 3
3.1 Suppose x = 3 and y = 2, show the output, if any, of the following code. What is the output if x = 3 and y = 4? What is the output if x = 2 and y = 2? Draw a flowchart of the following code:
if (x > 2) {
if (y > 2) {
int z = x + y;
System.out.println("z is " + z);
}
}
else
System.out.println("x is " + x);
3.2 Write an algorithm (flowchart or pseudocode) for the following problem:-
(Computing the perimeter of a triangle) Write a program that reads three edges for a triangle and computes the perimeter if the input is valid. Otherwise, display that the input is invalid. The input is valid if the sum of any two edges is greater than the third edge.
10/08/2012
10/06/2012
BCS2233 OOP Selection
1. Read age, if age bigger than or equal to 21 then print "Eligible to vote."
2. An electric supply company charges the following rates for its customers:-
No. of unit consumed Charges/unit (RM)
1-200 2.50
201 - 500 3.50
over 501 5.00
2. An electric supply company charges the following rates for its customers:-
No. of unit consumed Charges/unit (RM)
1-200 2.50
201 - 500 3.50
over 501 5.00
9/25/2012
BCS2233OOP first calculation program
1. (Computing the volume of a cylinder) Write a program that reads in the radius and length of a cylinder and computes volume using the following formulas:-
area = radius x radius x PI
volume = area x length
PI=3.14159
import java.util.Scanner;
/**
* @(#)Welcome.java
*
* Welcome application
*
* @author
* @version 1.00 2012/9/25
*/
public class Welcome {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Enter a num for radius");
double radius = input.nextDouble();
System.out.println("Enter a num for length");
double length = input.nextDouble();
double area,volume;
area = radius * radius * 3.14159;
volume = area * length;
System.out.println( volume);
}
}
Subscribe to:
Posts (Atom)
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. ...
-
1.TOPUP Cepat Susut Jika anda merasa topup prepaid anda cepat susut walaupun tak banyak call- ada baiknya anda semak log call/sms/content ...
-
Section 8 The String Class 8.1 Suppose that s1 , s2 , s3 , and s4 are four strings, given as follows: String s1 = ...
-
1. Jika anda bercadang untuk download windows 10 melalui website rasmi windows - pilihan untuk download dalam format ISO tidak di berikan. ...

