write a java program to find a perimetre of a rectangle
Answers
Answered by
2
Hi Friend, here I give u Java program to calculate area and perimeter of a rectangle
package com.tcc.java.programs; import java.util.*; p
ublic class RectangleAreaPerimeter
{ 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); }}
package com.tcc.java.programs; import java.util.*; p
ublic class RectangleAreaPerimeter
{ 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); }}
Answered by
0
Sample program to calculate and perimeter of the triangle:
public class Brainly
{
public static void main(long l, long b)
{
System.out.println("Entered length = "+l);
System.out.println("Entered breadth = "+b);
long perimeter = l + b;
System.out.println("Perimeter of the entered triangle = "+perimeter);
}
}
Output:
Entered length = 46
Entered breadth = 40
Perimeter of the entered triangle = 86
Attachments:
Similar questions