Music, asked by ayushgodse777, 3 months ago

Write a program to accept length and breadth of a rectangle. Calcul
and display the area, perimeter or diagonal of the rectangle as pe
the user's choice.​

Answers

Answered by StevenUniverse
2

Answer:

import java.util.*;

public class rectangle

{

public static void main()

{

Scanner sc =new Scanner (System.in);

System.out.println("enter length,breadth of rectangle");

double l=sc.nextDouble();

double b=sc.nextDouble ();

System.out.println ("enter choice");

int ch=sc. nextInt();

switch(ch)

{

case1:

double a;

a=l*b;

System.out.println ("area="+a);

break;

}

case 2:

{

double p;

p=2*(l+b);

System. out.println ("perimeter="+p);

break;

}

case 3:

{

double d=Math.sqrt(l*l+b*b);

System. out.println ("diagonal="+d);

break;

}

default :

{

System.out.println ("wrong choice");

}

}

}

Explanation:

Similar questions