Computer Science, asked by Pranjalkarki2, 1 year ago

write a program in Java to find the area and perimeter of rectangle by using assignment operator

Answers

Answered by SweetAnnanya
46
//To find the area,perimeter of a rectangle
public class Rectangle
{
public static void main(String args[])
{
int 1,b,ar,p;
double d;
1=24;b=10;
ar=1*b;
p=2*(1+b);
d=Math.sqrt(1*1+b*b);
System.out.println("The area of rectangle="+ar);
System.out.println("The perimeter of rectangle="+p);
}
}
Answered by shashanksingh9
8

public static void main(String[] args)

{

int l, b, perimeter, area;

Scanner s = new Scanner(System.in);

System.out.print("Enter length of rectangle:");

l = s.nextInt();

System.out.print("Enter breadth of rectangle:");

b = s.nextInt();

perimeter = 2 * (l + b);

System.out.println("Perimeter of rectangle:"+perimeter);

area = l * b;

System.out.println("Area of rectangle:"+area);

}

}

Similar questions