Q-) Write a menu-driven JAVA program to calculate:
(i) Area of a circle, Formula-
(ii) Area of rectangle, Formula-
(A=LENGTH*BREATH)
(iii) Exit the program.
[Who ever answers correct, will be marked as a BRAINLIEST, and THANKFUL.
And whoever answers SPAM, it will be reported..]
Please-Please answer.....
Answers
import java.util.*;
class menu
{
public static void main(String args[ ])
{
Scanner sc=new Scanner(System.in);
double r,l,b,area;
int ch;
System.out.println("1. Area of Circle");
System.out.println("2. Area of Rectangle");
System.out.println("3. Exit");
System.out.println("Enter your choice");
ch=sc.nextInt();
switch(ch)
{
case 1: System.out.println("Enter the Radius");
r=sc.nextDouble();
area=3.14*r*r;
System.out.println("Area of Circle "+area);
break;
case 2: System.out.println("Enter the length and breadth:);
l=sc.nextDouble();
b=sc.nextDouble();
area=l*b;
System.out.println("Area of Rectangle " +area);
break;
case 3: System.exit(0);
break;
default : System.out.println("You entered wrong choice ");
break;
}
}
}