11/30/2014

BCS2233 OOP:Lab 1 Dis - 4 Dis 2014

Write  a java program for the following problems using object oriented approach. 

1.  Develop a program to input height and length of a right triangle and calculate and print the area of a right triangle.

        Area of right triangle = (height x length) /2


2. Write a java program to input three integers and print the smallest and largest.


3.  An electric supply company charges the following rates for its customers:-

No. of unit consumed                              Charges/unit (RM) 
1     - 200                                                           0.218 
201 - 300                                                           0.334                                                   
>= 301                                                               0.516

Read unit consumed and calculates the net amount of the bill for each consumer and print it.








BCS2233 Chapter 8: Classes and Objects

Write a java program using both  structured and Objected Oriented approach to input length and width of a rectangle and calculate its area and parameter.
-------------------------------------------------Structured------------------------------------------
import java.util.Scanner;
public class calculateAreadanPerimeterofBox {
    
    public static void main(String[] args) {
    Scanner input= new Scanner(System.in);
    System.out.println("Sila Masukkan nilai tinggi dan lebar segiempat!");
        int tinggi = input.nextInt();
        int lebar =input.nextInt();
        
        int luasSegiempat=tinggi*lebar;
        int perimeterSegiEmpat = 2*(tinggi+lebar);
        
          System.out.println("Tinggi : " +tinggi);
         System.out.println("Lebar : " +lebar);
        System.out.println("Luas Segi Empat=" +luasSegiempat );
        System.out.println("Perimeter Segi Empat=" +perimeterSegiEmpat );
  }
}

----------------------------------------------------------------------------------------------------------------


-------------------------------------------------Object Ortiented ------------------------------------------
import java.util.Scanner;
class segi4{
int luas,perimeter, lebar,tinggi;

void baca_data(){
Scanner input= new Scanner(System.in);
System.out.println("Sila masukkan lebar dan tinggi bagi suatu segi empat :");
lebar=input.nextInt();
tinggi=input.nextInt();
}

void kira_luas(){
luas = lebar * tinggi;
}

void kira_ukurlilit(){
perimeter=(lebar + tinggi)*2;

}

void pamir_data(){
System.out.println("lebar: "+lebar);
System.out.println("tinggi:"+tinggi);
System.out.println("luas:"+luas);
System.out.println("Ukur Lilit / Perimeter : "+perimeter);
}

}
 
public class demoClass_and_Object {
    
    public static void main(String[] args) {
   
    segi4 mys4 =new segi4();
        mys4.baca_data();
        mys4.kira_luas();
        mys4.kira_ukurlilit();
        mys4.pamir_data();

    
    }
}

----------------------------------------------------------------------------------------------------------------

11/16/2014

BCS3473 OOAD Test 1 Preparation

Contoh Soalan Ujian 1

Chapter 1
What is the differences between an information systema dn information technology?
What is the purpose of a management support system.
Define information. How does it differs from data?

Chapter 2
What is the main underlying causes of probels in information systems development?
What is the main differences between quality problems and productivity problems?
Define stakeholder.

Chapter 3
What are the advantages of the traditional waterfall lifecycle?
What are the disadvantages of the traditional waterfall lifecycle?
What is prototyping?
How does prototyping differs from inceremental development?

Chapter 4
What is polymorphism?
What does it mean to say that an object oriented is highly modular?

11/15/2014

BCS2233 OOP : Array

Definition Array : Array is a data structure that represents a collection of the same types of data. 

1. Consider the following 1 dimensional array.int[] N[4] ={5,6,8,1,2};state the value for
I) N[0
]II) N[1
III) N[2]


2. Write program statements that will do the following to array X shown below: -
int[]  X= new int[20];

for(i=0;i<=19;i++)
X[i]=i;

I. Print all elements (use loop).

II. Replace third elements with 7.

III. Copy the elements in the fifth location into the first one.

IV. Increase the sixth element by 2.

V. Find the sum of the first nine elements.

VI. Multiply each of the first six elements by 2 and place each product in an element of the array named SecondArray. 

VII. Display all even-numbered elements.

for(?;?;?) {
System.out.println(X[i]);

}
3. Read 10 score and find how many score above the average.

4. A common operation is to determine the minimum or the maximum value stored in an array. Write a program that declare and initialize an array named score as follows.
int[] score[ 10 ] = { 4, 1, 5, 3, 4, 10, 9, 2, 1, 7 }; 
find the maximum value in array score. An algorithm for finding the maximum value is as follows:-

1. Assume that the first element is the largest so far and save its subscript as the subscript of the largest so far.
2. For each array element do
     If the current element is > than the largest so far then
     save the subscript of the current element as the subscript of the largest so far.


Solution (part of) question 2.
import java.util.Scanner;
public class demoarray2 {
   
    public static void main(String[] args) {
      
    int[] x = new int[10];
          
    int i;
    for(i=0;i<=9;i++){    // jana nombor rawak dan simpan dalam array x
        x[i]= (int)(Math.random()*101);
    }      
 
   //II. Replace third elements with 7.
   x[2]=7;
    //iii. Copy the elements in the fifth location into the first one
    x[0]=x[4];
   //IV. Increase the sixth element by 2.
  x[5]=x[5]+2;
  
  
     for(i=0;i<=9;i++){    // lihat nilai dalam array x
        System.out.println(x[i]);
    }
//V. Find the sum of the first nine elements.

int sum=0;
for(i=0;i<=8;i++){    // gantikan ?
        sum=sum+x[i];
    }
 System.out.println("Hasil tambah nilai x pertama hingga 9 ialah:"+sum);
}
//VII. Display all even-numbered elements.

for(i=0;i<=9;i=i+2) {        // gantikan ?
System.out.println(X[i]);

}

}

11/10/2014

BCS2233 OOP. Assignment 2

1. (GROUP: Nur Syahidatul Amin Bt Zain Azlan)Write an algorithm (pseudocode or flowchart) for a program that read 10 integers. Find the maximum and minimum number among the 10 (hint: use selection statements together with looping statements).


2. (GROUP: Nur Amirah Mohd Kamar)A Book Publisher offers discount to customers on the basis of customer type and number of copies ordered as shown below:

Customer Type

Number of Copies Ordered

% of Discount

Book Seller

More than 10

25

Less than or equal to 10

15

Library

More than 5

20

Less than or equal to 5

10


Customer number, name, type, book number, number of copies ordered and unit price are given as input. Draw a flowchart to calculate the net amount of the bill for each customer and print it.



3. (GROUP: Nur Hidayatul Hanis Zulkifli)(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. Display the average as a floating-point number. (For example, if you entered 1, 2, and 0, the average should be 1.5.)
4. (GROUP: Kavin Mithran A/L Sivanesan)Write a 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




5.  (GROUP: Wan Nur Atira Bt Wan Abdul Faris)(Summing a series) Write a program to sum the following series:






6. (GROUP BCNS) A nested loop is a loop within a loop, an inner loop within the body of an outer one. How this works is that the first pass of the outer looptriggers the inner loop, which executes to completion. Then the second pass of the outer loop triggers the inner loop again.


Looping i and Looping J (separately)

Looping is outer while Looping J is inner


7. (GROUP : Muhamad Razif Hafifi). What does the following flowchart do?

11/09/2014

BCS2233 OOP. LAB week 8 (9-13 Nov 2014)

A. Write method headers for the following methods:

1. Computing a sales commission, given the sales amount and the commission rate.
2. Printing the calendar for a month, given the month and year.
3. Computing a square root.
4.Testing whether a number is even, and returning true if it is.
5.Printing a message a specified number of times.
6.Computing the monthly payment, given the loan amount, number of years, and annual interest rate.
7.Finding the corresponding uppercase letter, given a lowercase letter.



Selected Solution

A
1. public static double cal_comm(double sa, double comm)
2. public static void MYCalender(int year, int month)





public class demoMethod {
public static double cal_comm(double sa, double comm){
//1. Computing a sales commission, given the sales amount
//and the commission rate.
double bayaran;
bayaran = sa * (comm/100);
return bayaran;
}
   
    public static void main(String[] args) {
    double jum_jual=1000;
    double kadar_komisyen=15;
    System.out.println(cal_comm(jum_jual,kadar_komisyen));
    }
}



11/04/2014

BCS2233 OOP. Lab 5/11/2014

(Finding the highest score) 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.

import java.util.Scanner; 
public class lab5okt2014 {
    
    public static void main(String[] args) {
    int counter =1;
    Scanner input = new Scanner(System.in);
    System.out.println("sila masukkan jumpelajar");
    int jum_p= input.nextInt();
    System.out.println("sila masukkan nama dan markah");
        String maxNama= nama;
        int maxScore = score;
        
        while(counter<=jum_p){
        counter++;
        System.out.println("sila masukkan nama dan markah pelajar");
        nama = input.next();
        score = input.nextInt();
         if(score>maxScore){
         maxScore=score;
         maxNama=nama;
         }  // end utk if
        } // end utk while
   
       System.out.println("Pelajar dengan markah paling tinggi ialah : ");
       System.out.println(maxNama+maxScore);    
    } 
}


11/03/2014

BCS2233 OOP. Assignment 2

Here are some of the problems that student need to demonstrate its logic.
An algorithm for the problems will be published later.

1. Write an algorithm (pseudocode or flowchart) for a program that read 10 integers. Find the maximum and minimum number among the 10 (hint: use selection statements together with looping statements).


2. A Book Publisher offers discount to customers on the basis of customer type and number of copies ordered as shown below:

Customer Type

Number of Copies Ordered

% of Discount

Book Seller

More than 10

25

Less than or equal to 10

15

Library

More than 5

20

Less than or equal to 5

10

 

Customer number, name, type, book number, number of copies ordered and unit price are given as input. Draw a flowchart to calculate the net amount of the bill for each customer and print it.

 



3. (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. Display the average as a floating-point number. (For example, if you entered 1, 2, and 0, the average should be 1.5.)

4.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
5.  (Summing a series) Write a program to sum the following series: 







6. A nested loop is a loop within a loop, an inner loop within the body of an outer one. How this works is that the first pass of the outer looptriggers the inner loop, which executes to completion. Then the second pass of the outer loop triggers the inner loop again.

11/02/2014

BCS2233 Contoh Ujian 1 Object Oriented Programming.

A.  Response to the following statements by circling either T (TRUE) or F (FALSE). [10M]

        I.            1. Java enables users to develop and deploy applications on the Internet for servers, desktop computers, and small hand-held devices.( T / F)

   2. Java is one of language that support object oriented programming. ( T / F)

 3. Reserved words or keywords are words that have a specific meaning to the compiler and cannot be used for other purposes in the program. ( T / F)

4. System.out.println is one of the pre-defined methods in Java. ( T / F)


  5. An identifier is a sequence of characters that consist of letters, digits, underscores (_), and dollar signs ($).( T / F)

B. Match the following Statement / Name to it descriptions.


No
Statements

Description
        I.  
x = 1;

Constants
      II.  
int x = 1;

Addition
    III.    
double radius;

Declaring and Initializing
    IV.  
final int SIZE = 3;

Multiplication
      V.  
+

Assignment Statements
    VI.    
*

Remainder
  VII.   
%

Declaring Variables


C. Answer the following questions


         I.            What is debugging? [2 marks]




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

  
D. Which of the following are invalid identifiers, why? [7 marks]

                     I.            one
                   II.            hello_there
                 III.            hello,there
                 IV.            my    Window
                   V.            JAVA
                 VI.            1234
               VII.            acct122 

E. Evaluate the following expressions: [4 marks]

                    I.            10 + 2 / 2
                  II.            3 * 3 + 3 % 2
                III.            3 + 2 / 5 + -2 * 4
                IV.            2 * (1 + -(3/4) / 2) * (2 - 6 % 3)

F. (Computing the volume of a cylinder) Write an algorithm and a Java program that reads in the radius and length of a cylinder and computes its volume using the following formulas: [20 marks]
   Area
= radius * radius * p
  volume
= area * length


G. (Finding the largest) Write an algorithm and a java  program that input ten integers and find the largest. [20 marks]


BCS2233 Object Oriented Programming

Quiz 1


Penggunaan
Caj
Minima (RM)
Kuantiti M3
(Meter Padu)
Caj
Setiap M3
0 - 20.00
RM0.42
RM4.00 sebulan
20.1 - 40.00
RM0.65
40.1 - 60.00
RM0.90
60.1 ke atas
RM1.00


Draw a flowchart to calculated the net amount of the bill for each consumer and print it.

Solutions


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