Computer Science, asked by siva4969, 1 year ago

write a program to accept length and breadth of rectangle. Calculate and display area and perimeter of rectangle​

Answers

Answered by amanpathak8833
1

Answer:

in which language buddy? ??

Answered by Anonymous
2

import java.util.*;

public class Menu

{

public static void main {String args[] }

{

Scanner in = new Scanner (System.in)

int l, b , n, a , p;

double d;

System.out.println( "Enter length and breadth of a rectangle");

a = in.nextInt();

b = in.nextInt();

System.out.println( "Enter 1 for area, 2 for perimeter, 3 for diagonal);

System.out.println("Enter your choice");

n = in.nextInt();

switch (n)

{

case 1:

a = l*b;

System.out.println("Area of rectangle =" +l);

break;

case 2:

p = 2(l+b);

System.out.println("Perimeter of rectangle =" +p);

break;

case 3;

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

System.out.println("Diagonal of rectangle =" +d);

break;

default:

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

}

}

}

Similar questions