A rectangle is a quadrilateral with four right angles.
Say rectangle is given with side’s length A and B
Area of Rectangle = A * B
Perimeter of rectangle = 2(A+B)
Code:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class AreaOfRectangle { | |
public static void area(double a, double b){ | |
double area = a * b; | |
System.out.println("Area of Rectangle: " + area); | |
} | |
public static void perimeter(double a, double b){ | |
double perimeter = 2*(a + b); | |
System.out.println("Perimeter of Rectangle: " + perimeter); | |
} | |
public static void main(String[] args) { | |
double a = 3; | |
double b = 4; | |
area(a, b); | |
perimeter(a, b); | |
} | |
} |
Output:
Area of Rectangle: 12.0 Perimeter of Rectangle: 14.0