JAVA RECORD PROGRAM FOR AREA AND PERIMETER OF RECTANGLE
// Java program to calculate the area and perimeter of a rectangle using class concept import java.util.*; // Rectangle Class File class Rectangle { // data members int length, width; // methods //constructor to create Object Rectangle(int length, int width) { this. length = length; this.width = width; } // prints the area of rectangle public void area() { int areaOfRectangle; areaOfRectangle = this.length * this.width; System.out.println("Area of rectangle with the given input is : " + areaOfRectangle); } // prints the perimeter of rectangle public void perimeter() { int perimeterOfRectangle; perimeterOfRectangle = 2 * (this...
Comments
Post a Comment