Write a program to enter the length and diagonal of a rectangle and print its area and perimeter.
Answers
Answered by
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
2
Answer:
This is the best answer.
Hope it helps
Please follow.
Please thanks.
Attachments:
Similar questions