4/12/2017

BCS2233 OOP : Programming Exercise1

Programming Exercise 1.
(please provide flowchart and java program for each question. You can create flowchart online  at https://www.draw.io/)

1. (Calculate body mass index (BMI) ) Write a program that reads a Weight and Height, then calcculate BMI and  displays the result . The formula for the BMI is as follows:
BMI = Weight / (Height x Height);

2. (Converting Fahrenheit to Celsius) Write a program that reads a Fahrenheit degree, then converts it to Celsius and displays the result . The formula for the conversion is as follows:
celsius = (5/9) * (fahrenheit - 32)

Hint
In Java, 5 / 9 is 0, so you need to write 5.0 / 9 in the program to obtain the correct result.


3. (Computing the volume of a cylinder) Write a program that reads in the radius and length of a cylinder and computes its volume using the following formulas:

area = radius * radius * pi
volume = area * length

(pi = 3.14)








Solution
Question 1.
 import java.util.Scanner;
public class hello1 {
   
    public static void main(String[] args) {
       
        Scanner input = new Scanner(System.in);
   
    // Prompt the user to enter weight in KG
    System.out.print("Enter weight in Kilogram: ");
    double weight = input.nextDouble();
   
    // Prompt the user to enter height in Meters
    System.out.print("Enter height in Meters: ");
    double height = input.nextDouble();
   
       
    // Compute BMI
        double bmi = weight /  (height * height);

    // Display result
    System.out.println("Your BMI is " + bmi);
   
    }
}

1/29/2017

Dapatkan balik fail yang di padam dan memadam fail secara kekal

1. Jika fail anda yang tersalah dipadam masih berada di dalam "recycle bin" maka anda bernasib baik kerana dengan mudah anda boleh "restore"nya semula.

2. Jika tidak - anda boleh mencuba menggunakan beberapa perisian untuk mendapatkannya semula. Antara perisian yang saya selalu gunakan ialah WinAso Registry Optimiser. Perisian lain yang boleh di gunakan adalah seperti Recuva.


3. Fail yang anda padam sebenarnya masih berada di situ cuma sistem komputer hanya menandakan bahawa lokasi storan tersebut bebas.

4. Jika anda mempunyai fail-fail sulit dan ingin memadamkan secara kekal - anda perlu menggunakan perisian tertentu seperti:-

Eraser - untuk padam fail fail terpilih.


Darik's Boot and Nuke - untuk padam Hard Disk secara menyeluruh

5. Selain dari beberapa nama yang saya sebutkan di atas - terdapat puluhan perisian lain yang menyediakan servis untuk tujuan yang sama. Buat sedikit carian dan anda akan dapat yang sesuai. InsyaAllah.

10/05/2016

DCT1093 OOP. Makmal 6 okt 2016

1. Tuliskan program di bawah dan "run" beberapa kali menggunakan input yang betul (nilai integer) dan input yang salah (nilai selain integer).
Bagaimana untuk menghalang "run time error" dari berlaku?

import java.util.Scanner;
public class demoexceptionHandling {   
    public static void main(String[] args) {
    Scanner input = new Scanner(System.in);
    int N = input.nextInt();  
    System.out.println(N );
    }
    }


__________________________________________________________________
2. Bina Rajah UML

Draw UML diagram for the class Point and class Circle as described below.

 A base class named Point consisting of x and y data members representing point coordinates. From this class, derive a class named Circle with another data member named radius. For this derived class, the x and y data members represent a circle’s centre coordinates. The member method of the Point class should consist of a constructor that set the value for x and y to 0, an area() method that return 0, and distance() method that returns the distance between two points.

Additionally, the derived class should has an overided method named area() that return’s a circle area

9/26/2016

BCT1113 Computer Programming Semester 1 2016 2017

Assalamualaikum wbkt. 

My Name is Mohd Nazri and I am going to teach you (BMPM students) computer programming. Here are the lists of some materials that are going to be used during the semester.



2.Powerpoint Slides


Introduction to Algorithm (Flowchart and Pseudocode)


3. Lab Sheet



4. Source Code Editor
A source code editor is a text editor program designed specifically for editing source code of computer programs. The Bloodshed Software - Dev-C++ will be used. 
you may download the software using the following link.
and the guide for installations can be found here.



9/24/2016

DCT1093 Assignment 3

Updated on 26 September 2016.

Problem Description:
 (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 a rectangle object with the width =10,  height =15 and color is "RED". Use the getArea() method to print the area of rectangle and getPerimeter() method to print the perimeter of a rectangle.


9/17/2016

DCT1093 OOP. LAB. Creating Object and Class


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

---------------------------------------------
half way


public class lab17sept2016 {
   
    public static void main(String[] args) {
    // cara bina objek
       
    Rectangle segi4    = new Rectangle();
    System.out.println(segi4.color);
    System.out.println(segi4.height);
    System.out.println(segi4.width);
   
    Rectangle segiempat    = new Rectangle(10,15);
    System.out.println(segiempat.color);
    System.out.println(segiempat.height);
    System.out.println(segiempat.width);
   
    }
}

class Rectangle{
double width=1;
double height=1;
String color="white";

//A no-arg constructor that creates a default rectangle.
Rectangle(){
}

//A constructor that creates a rectangle with the specified width and height
Rectangle(double newWidth, double newheight){
width = newWidth;
height = newheight;
}

//The accessor (get) and mutator(set) methods for all three data fields.
double getwidth(){
return width;
}

double getheight(){
return height;
}
String getcolor(){
return color;
}

void setwidth(double newWidth){
width =newWidth;
}

void setheight(double newheight){
height =newheight;
}
void setcolor(String newColor){
color = newColor;
}

double getArea(){
return (width * height)    ;
}
double getPerimeter(){
return (2*(width + height))    ;
}


}





2. (The Account class) Design a class named Account that contains:
An int data field named id for the account (default 0).

A double data field named balance for the account (default 0).

A double data field named annualInterestRate that stores the current interest rate (default 0).

A Date data field named dateCreated that stores the date when the account was created.

A no-arg constructor that creates a default account.

The accessor and mutator methods for id, balance, and annualInterestRate.

The accessor method for dateCreated.

A method named getMonthlyInterestRate() that returns the monthly interest rate.

A method named withDraw that withdraws a specified amount from the account.

A method named deposit that deposits a specified amount to the account.

Draw the UML diagram for the class. Implement the class. Write a test program that creates an Account object with an account ID of 1122, a balance of 20000, and an annual interest rate of 4.5%. Use the withdraw method to withdraw $2500, use the deposit method to deposit $3000, and print the balance, the monthly interest, and the date when this account was created.
--------------------------------------------------------------------------------------------------------------------
public class Test {
  public static void main (String[] args) {
    Account account = new Account(1122, 20000);
    Account.setAnnualInterestRate(4.5);
    
    account.withdraw(2500);
    account.deposit(3000);
    System.out.println("Balance is " + account.getBalance());
    System.out.println("Monthly interest is " +
    account.getMonthlyInterest());
    System.out.println("This account was created at " +
      account.getDateCreated());
  }
}

Class Account {

  // Implement the class here

}


8/20/2016

DCT1093 OOP : Assignment 2

1. Write a Java program based on the following flowchart:-








2. Please provide:-
(i) Algorithm (Flowchart or  Pseudocode) and
(ii) Java Program

for the following problems.


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.


Due Date : 8 / 9 / 2016

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