Computer Science, asked by singhnandni643, 4 months ago

write a program in java to find perimeter of rectangle​

Answers

Answered by armaans5tha
1

so I begin with scanner class

import java.util.Scanner;

public class AreaAndPerimeterOfRectangle

{

public static void main(String[] args)

{

Scanner in = new Scanner(System.in);

System.out.print("Enter the Length: ");

double length = sc.nextDouble();

System.out.print("Enter the Breadth: ");

double breadth = sc.nextDouble();

sc.close();

double area = length * breadth;

double perimeter = 2 * (length + breadth);

double diagonal = Math.sqrt((length * length) + (breadth * breadth));

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

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

System.out.println("Length of diagonal: " + diagonal);

}

}

Hope it helps

Similar questions