SHARE
TWEET

Subal (Rectangle.java)

a guest Mar 21st, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5. package shape;
  6.  
  7. /**
  8.  *
  9.  * @author user
  10.  */
  11. public class Rectangle {
  12.     private double length;
  13.     private double width;
  14.     public Rectangle() {
  15.        
  16.     }
  17.     public Rectangle(double length, double width) {
  18.         this.length = length;
  19.         this.width = width;
  20.     }
  21.     public double area(double length, double width) {
  22.         return (length * width);
  23.     }
  24.     public double perimeter (double length, double width) {
  25.         return (2 * (length + width));
  26.     }
  27.     public void area() {
  28.         System.out.println("Area of the Rectangle: " + (length * width));
  29.     }
  30.    
  31.     public void perimeter () {
  32.         System.out.println("Perimeter of the Rectangle: " + (2 * (length + width)));
  33.     }
  34. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top