Write a program to input the length and breadth of a rectangle and display its area and perimeter. in qb64
Answers
JAVA-
import.java.util*
Class Program
{
public static void main()
{
double L,B,A,P;
Scanner sc=new Scanner(System.in);
System.out.println("Enter Length and Breadth");
L=sc.nextDouble();
B=sc.nextDouble();
A= L*B;
P= 2(L+B);
System.out.println("Area"=+A);
System.out.println("Perimeter"=+P);
}
}
}
Hopefully this helps, if so mark me brainliest or simply give a thanks.
Answer:
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 !!");
}
}
}