Computer Science, asked by RISHAV1001, 1 month ago

Write a program to enter the length and diagonal of a rectangle and print its area and perimeter.​

Answers

Answered by emailsanjaypatil
1

Explanation:

import java.util.Scanner;

public class AreaAndPerimeterOfRectangle {

public static void main(String[] args) {

// Taking inputs from user

Scanner sc = 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);

Attachments:
Answered by Anonymous
2

Answer:

This is the best answer.

Hope it helps

Please follow.

Please thanks.

Attachments:
Similar questions