0% found this document useful (0 votes)
3 views1 page

Java Class for Rectangle Area & Perimeter

The document contains a Java program that defines a Rectangle class. This class includes methods to calculate and print the area and perimeter of a rectangle based on its length and breadth. The program demonstrates basic object-oriented programming concepts in Java.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

Java Class for Rectangle Area & Perimeter

The document contains a Java program that defines a Rectangle class. This class includes methods to calculate and print the area and perimeter of a rectangle based on its length and breadth. The program demonstrates basic object-oriented programming concepts in Java.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

// Java program to create a class to

// print the area and perimeter of a


// rectangle

public class Rectangle


{

// Variable of data type double


double length;
double breadth;

// Area Method to calculate the area of Rectangle


void Area()
{
double area;
area = [Link] * [Link];
[Link]("Area of rectangle is : "
+ area);
}

// Perimeter Method to calculate the Perimeter of


// Rectangle
void Perimeter()
{
double perimeter;
perimeter = 2 * ([Link] + [Link]);
[Link]("Perimeter of rectangle is : "
+ perimeter);
}
}

You might also like