Showing posts with label 13/14 SEM 1 BCS2233. Show all posts
Showing posts with label 13/14 SEM 1 BCS2233. Show all posts

12/09/2013

BCS2233 OOP: Quiz 4

Name:_______________________
Matric:_______________________
Course:_______________________

CHAPTER 12

1. Explain the difference between AWT GUI components, such as java.awt.Button, and Swing components, such as javax.swing.JButton.


2. Show the output of the following java code:

import javax.swing.*;

public class Test {
  public static void main(String[] args) {
    JButton jbtOK = new JButton("OK");
    System.out.println(jbtOK.isVisible());

    JFrame frame = new JFrame();
    System.out.println(frame.isVisible());
  }
}

12/01/2013

BCS2233 OOP: Quiz 3

Name:_______________________
Matric:_______________________
Course:_______________________


A. TRUE/ FALSE (5 Marks)

1. You can derive a new class from an existing class. This is called  as class inheritance. (T/F)
2. The new class (derived class ) is called a superclass. The existing class is called child class.(T/F)
3. Constructors are a special kind of methods that are invoked to construct objects(T/F)
4. To override a method, the method must be defined in the derived class  using the same signature as in its existing class.(T/F)
5. All method including  a private method can be overridden.(T/F)

B. Design a class named person and its two subclasses named student and employee. A person has a name, address, phone, and email address. A student has a status. An employee has an department, salary and date hired.

Draw the UML diagram for the classes.

(10 Marks)


* untuk soalan B. 1. Bina Class (tak perlu buat program penuh) 2. Lukis UML.

pls submit before 5:00 pm.

11/24/2013

BCS2233 OOP: Quiz 2

1. TRUE / FLASE (5 Marks)



a) A Java class uses variables to define data fields and methods to define behaviors.(T/F)
b) An object is an instance of a class. (T/F)
c) You use the new operator to create an object.(T/F)
d) The dot (.) operator to access members of that object through its reference variable.(T/F)



2. Consider the following java code. Draw the UML diagram for the class cubee.(5 Marks)


import java.util.Scanner;

public class class1_triangle {
  
    public static void main(String[] args) {
      
           cubee mycube= new cubee();
        mycube.inputdata();
      
        System.out.println("Area of a cube is " + mycube.get_area());
        System.out.println("Perimeter of a cube is " + mycube.get_parameter());     
    }
}


class cubee
{
   int width;


void inputdata()
{
   System.out.println("Please enter width of a cube ");
   Scanner input = new Scanner(System.in);
   width = input.nextInt();

}

double get_area()
{
   return (width * width*width);
}


double get_parameter()
{
   return width*12;
}

}



11/18/2013

BCS2233 OOP: Assignment 2 & 3

ASSIGNMENT 2

1. Write method headers for the following methods:


   a. Computing a sales commission, given the sales amount and the commission rate.
    b. Printing the calendar for a month, given the month and year.
    c. Computing a square root.
    d. Testing whether a number is even, 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.
2. (Analyzing input) Write a program that reads ten numbers, computes their average, and finds out how many numbers are above the average.

3. (Reversing the numbers entered) Write a program that reads ten integers and displays them in the reverse of the order in which they were read.

ASSIGNMENT 3

1. Define the following terms:-
a. class
b. object
c. data
d. properties
e. behaviour
f. method
g. constructor
h. destructor
2.  (The Rectangle class) Design a class named Rectangle to represent a rectangle. The class contains:
Two double data fields named width and height that specify the width and height of the rectangle. The default values are 1 for both width and height.

A string data field named color that specifies the color of a rectangle. Hypothetically, assume that all rectangles have the same color. The default color is white.

A no-arg constructor that creates a default rectangle.

A constructor that creates a rectangle with the specified width and height.

The accessor and mutator methods for all three data fields.

A method named getArea() that returns the area of this rectangle.

A method named getPerimeter() that returns the perimeter.

 Draw the UML diagram for the class. Implement the class. Write a test program that creates two Rectangle objects. Assign width 4 and height 40 to the first object and width 3.5 and height 35.9 to the second object. Assign color red to all Rectangle objects. Display the properties of both objects and find their areas and perimeters.

11/11/2013

BCS2233 OOP : LAB WEEK 10

Read ten numbers, compute their average, and find out how many numbers are above AND BELOW the average.

refer to powerpoint slide page 3 on chapter 6 for the solution.

10/29/2013

BCS2233 OOP : Ujian 1

Cadangan Ujian 1 satu adalah seperti berikut:-
Tarikh: 13/11/2013 (Rabu)
Masa: 8:30 MALAM
Tempat: THRT A


Topik dan format adalah seperti berikut:-
Chapter 1
1.1 Describe the history of Java. Can Java run on any machine? What is needed to run Java on a computer?
1.2 What are the input and output of a Java compiler?

1.3 Explain the Java keywords. List any five Java keywords
1.4 Is Java case-sensitive?
1.5 What is the Java source filename extension, and what is the Java bytecode filename extension?
1.6 What is a comment? What is the syntax for a comment in Java? Is the comment ignored by the compiler?

Chapter 2

2.1 Translate the following pseudocode into Java code:

Step 1: Declare a double variable named MILES with initial value 1000;


Step 2: Declare a double constant named MILE_TO_KILOMETER with value 1.609;


Step 3: Declare a double variable named KILOMETER, multiply miles and MILE_TO_KILOMETER and assign the result to kilometer;


Step 4: Display kilometer to the console.


2.2 Identify and fix the errors in the following code:
 1 public class Test {
 2   public void main(string[] args) {
 3     int i;
 4     int k = 100.0;
 5     intj = i + 1;
 6
 7     System.out.println("j is " + j + " and
 8       k is " + k);
 9   }
10 }


chapter 3

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);



Chapter 4

4.1 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

Write an algorithma and java program for each of the following problems:-

1. Write a program to continuously read in integers and stop when a negative number is entered. 
2. 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.


10/28/2013

BCS2233 OOP : LAB WEEK 8

Reduce the length of code of   the following java  program by adding repetition and method for a suitable parts.

import java.util.Scanner;

/**
 Write a program to Compute a sales commission for a three persons, read the sales amount and the commission rate.
 */

public class method1 {
  
    public static void main(String[] args) {
      
        double sales_amount, commission_rate,commision;
        Scanner scanner = new Scanner(System.in);
 //---------------baca data pertama----------------------------
        System.out.println("Sila masukkan jumlah jualan dan kadar komisen");
        sales_amount = scanner.nextDouble();
        commission_rate=scanner.nextDouble();
 //----------------kira komisen dan cetak -----------------------
        commision= (commission_rate /100) * sales_amount;
        System.out.println("Komisen anda ialah RM " +commision );
      
  //---------------baca data kedua----------------------------
        System.out.println("Sila masukkan jumlah jualan dan kadar komisen");
        sales_amount = scanner.nextDouble();
        commission_rate=scanner.nextDouble();
 //----------------kira komisen dan cetak -----------------------
        commision= (commission_rate /100) * sales_amount;
        System.out.println("Komisen anda ialah RM " +commision );
      
   //---------------baca data ketiga----------------------------
        System.out.println("Sila masukkan jumlah jualan dan kadar komisen");
        sales_amount = scanner.nextDouble();
        commission_rate=scanner.nextDouble();
 //----------------kira komisen dan cetak -----------------------
        commision= (commission_rate /100) * sales_amount;
        System.out.println("Komisen anda ialah RM " +commision );
     
    }
}

10/21/2013

BCS 2233 OOP lab week 7

1. Tuliskan program java bagi flowchart berikut (sebagaimana di bincangkan dalam kelas)







 2. Tuliskan program java bagi flowchart berikut (penambahan pada aobjek yang di warnakan merah dan perubahan pada objek yang di warnakan kuning.






3. Ubah flowchart supaya program akan tamat jika 3 kali 0 (kosong) di inputkan secara berturut-turut.


9/30/2013

BCS2233 OOP. Assignment 1

Write an algorithm (either flowchart or pseudocode) and java program for each of the following problem.

1. (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. Your program ends with the input 0.

2. (Summing a series) Write a program to sum the following series:





3. Write a test program that prompts the user to enter the investment amount (e.g., 1000) and the interest rate (e.g., 9%), and print a table that displays future value for the years from 1 to 30, as shown below:

The amount invested: 1000
Annual interest rate: 9%
Years       Future Value
  1          1093.8
  2          1196.41
...
 29         13467.25
 30         14730.57




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.  ...