write a menu driven program to find the area of a circle ,perimeter of rectangle and area of quadrilateral
Answers
Answer:
Using python here you go:
_____________________________
print("Enter 1 for area of circle, 2 for perimeter of rectangle and 3 for area of a quadrilateral.")
inp=int(input("Enter your choice: "))
if inp==1:
r=float(input("Enter the radius length: "))
print("The area will be",round(3.14*(r**2),2), "unit squared.")
elif inp==2:
l=float(input("Enter the length: "))
b=float(input("Enter the breadth: "))
print("The perimeter will be", 2*(l+b), "units.")
elif inp==3:
d=float(input("Enter the diagonal: "))
p1=float(input("Enter the 1st perpendicular length: "))
p2=float(input("Enter the 2nd perpendicular length: "))
print("The area will be ", round(0.2*d*(p1+p2),2),"unit squared.")
else:
print("Not a valid choice" )
___________________________________________________
import java.util.*;
class calculation
{
public static void main (String args[])
{
int choice;
double area;
double perimeter;
int r;
int l,b;
int diag;
Scanner sc=new Scanner(System.in);
System.out.println("Enter 1 for area of circle");
System.out.println("Enter 2 for perimeter of rectangle");
System.out.println("Enter 3 for area of a quadilateral");
System.out.println("_______________________");
System.out.println("select your choice=");
choice=sc.nextInt();
switch(choice)
{
case 1:
System.out.print("Enter r=");
r= sc.nextInt();
area= r*r*22/7;
System.out.println("area of a circle="+area);
break;
case 2:
System.out.print("Enter l=");
l=sc.nextInt();
System.out.print("Enter b=");
b=sc.nextInt();
perimeter=2*(l+b);
System.out.println("perimeter of rectangle="+perimeter);
break;
case 3:
System.out.print("Enter l=");
l=sc.nextInt();
System.out.print("Enter b=");
b=sc.nextInt();
area=l*b;
System.out.println("area of a quadrilateral"+area);
break;
default:
System.out.println("incorrect choice");
}
}
}