3/11/2015

BCS2233 OOP: Determine Count Control Loop or Sentinel Control Loop


I.    Write a java statement to print integer 50 to 60.


II.    Write a java statement to print integer 10 down to 0.


III.    Write a java statement to print the following output.
5    10    15    20    25    30


IV.    Write a java statement to add EVEN  integers  1through 10.


V.    Write a java  statement to continuously read in integers and stop when a negative number is entered.


VI.    Write a java statement to continuously read in integers and stop when a 100 is entered.   



3/09/2015

DCT1093 OOP: Asgmt 3.

Assignment 3

1. Write a java program to input a length and width of a right triangle and output it area and perimeter. Use object oriented programming techniques based on *following UML class diagram.

*will be discussed in class


2. Write a class for each of the following specifications. In each case, include a constructor that set each member values to 0, a method named inputdata() that will prompt user to enter all values for it member data  and a member method named showdata() that can be used to display member values.

i)     A class named time that has integer data members named secs, mins, and hours.                                                                                        
import java.util.Scanner;
class time{
int secs,mins,hours;


time(){
secs=mins=hours=0;
}
void input_data(){
System.out.println("Sila masukkan saat, minit dan jam");
Scanner input = new Scanner(System.in);
secs = input.nextInt();
mins = input.nextInt();
hours = input.nextInt();
}

void showdata(){
System.out.println("Saat="+secs);
System.out.println("Minit="+mins);
System.out.println("Jam ="+hours);
}
}

public class asgmt3qa {
   
    public static void main(String[] args) {
       
        time mytime = new time();
        mytime.showdata();
        mytime.input_data();
        mytime.showdata();
    }
}

ii)    A class named rectangle that has integer data members named height and length.                                        

3/08/2015

BCS2233 OOP: LAB WEEK 7

1. Consider the following flowchart. Identify:-
1.1 Selection
1.2 Repitition

2. Code the following flowchart (flowchart 1) in Java Program.

Flowchart 1
 
* the following java code can be used to generate random number in range of 0 to 100:-
int X = (int)(Math.random() * 101);
 
3. Consider the following flowchart. What is the difference ?
Flowchart 2
 
 4. Code the following flowchart (flowchart 2) in Java Program.
import java.util.Scanner;
 
public class guessNumber2 {
    
    public static void main(String[] args) {
    // Generate a random number to be guessed
    int X = (int)(Math.random() * 101);
    int jumlah_tekaan=0;
    Scanner input = new Scanner(System.in);
    System.out.println("Sila teka satu nombor antara 0 hingga 100");

    int teka = -1;
    while (teka != X) {
      // Prompt the user to guess the number
      System.out.print("\nMasukkan Nombor anda: ");
      teka = input.nextInt();
      jumlah_tekaan++;
      if (teka == X)
        System.out.println("Tahniah! Tekaan anda tepat--> " + teka);
      if (teka > X)
        System.out.println("Tekaan Anda Terlalu Besar");
      if (teka < X)
        System.out.println("Tekaan Anda Terlalu Rendah");
    } // End of loop 
    
    System.out.println("Jumlah Tekaan Anda ialah :" +jumlah_tekaan);
     
    }
}
 

3/07/2015

dct1093 oop; lab week 14

import java.util.Scanner;
class segitiga{   // nama kelas ialah segitiga
int lebar;          // ada dua data iaitu lebar dan tinggi
int tinggi;

void Input_Data(){ // method untuk input lebar dan tinggi
Scanner input= new Scanner(System.in);
System.out.println("Sila masukkan lebar dan tinggi ");
lebar = input.nextInt();
tinggi = input.nextInt();
}

double Kira_Luas(){ // method utk kira luas segitiga

return (0.5*(tinggi*lebar));
}

double Kira_Ukurlilit(){
 return (100);  // saya tak ingat formula
}

void Display_Data(){  // method utk paparkan lebar, tinggi,
                        // luas dan ukurlilir segitiga
System.out.println("Maklumat untuk sebuah segitiga :-");
System.out.println("Lebar "+lebar);
System.out.println("Tinggi "+tinggi);
System.out.println("Luas "+Kira_Luas());
System.out.println("Tinggi "+Kira_Ukurlilit());
}  
}                  
public class ooplabweek14 {
  
    public static void main(String[] args) {
      
        // TODO, add your application code
        System.out.println("Hello World!");
        segitiga segi3pertama = new segitiga();
        segi3pertama.Input_Data();
        segi3pertama.Display_Data();
      
        segitiga segi3kedua = new segitiga();
        segi3kedua.Input_Data();
        segi3kedua.Display_Data();
      
    }
}

3/04/2015

DCT1093 OOP: Markah Untuk 'Assignment 2'

Markah untuk 'Assignment 2' adalah seperti berikut:-


Markah Untuk Assignment 2

Posting Berkaitan

3/01/2015

BCS2233 OOP: LAB (Selection)


  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.

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