Write a JAVA program to find the area and perimeter of a square and rectangle. Store side in s , length as 'ln' and breadth as 'b'. display the results in separate lines. DO NOT USE ANY INPUT METHOD
Answers
Answered by
3
Answer:
public class area_perimeter
{
public static void main(String[]args)
{
int s = 20;
//example for side is 20
int ln= 40;
//example for side is 40
int b=30;
//example for side is 30
int area_square , area_rectangle , perimeter_square , perimeter_rectangle,area_square = s*s ;
area_rectangle = ln*b ;
perimeter_square = 4*s;
perimeter_rectangle = 2*(l+b);
System.out.println("area of the square=" + area_square);
System.out.println("area of the rectangle="+area_rectangle);
System.out.println("perimeter of the square="+perimeter_square);
System.out.println("perimeter of the rectangle="+perimeter_rectangle);
}
}
Explanation:
Similar questions