Advertisement
Guest User

Subal (Rectangle.java)

a guest
Mar 21st, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.82 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement