write a Java program accept length and breadth of a rectangle calculate and print area and perimeter of a rectangle
Answers
Answer:
/* ............... START ............... */
import java.util.*;
public class JavaAreaAndPerimeterOfRectangle {
public static void main(String args[]) {
int length, width, area, perimeter;
Scanner in = new Scanner(System.in);
System.out.println("Enter length of Rectangle");
length = in.nextInt();
System.out.println("Enter width of Rectangle");
width = in.nextInt();
// Area of rectangle = length X width
area = length * width;
// Perimeter of rectangle = 2 X (length X width)
perimeter = 2 * (length + width);
System.out.println("Area of Rectangle : " + area);
System.out.println("Rectangle of Rectangle : " + perimeter);
}
}
/* ............... END ............... */
Output
Enter length of Rectangle
5
Enter width of Rectangle
6
Area of Rectangle : 30
Rectangle of Rectangle : 22
Explanation: