write a menu driven program using user's choice to perform the following operations volume of a cube is equals to s * s * s volume of a sphere is equals to 4/3 * 22/7*r*r*r volume of a cuboid is equals to l * b *h
Answers
Answer:
import java.util.*;
class hlo
{
public static void main (String args [])
{
Scanner sc=new Scanner (System.in);
System.out.println("Enter 1 for cube");
System.out.println("Enter 2 for sphere");
System.out.println("Enter 1 for cuboid");
int ch=sc.nextInt();
switch (ch)
{
case 1:
System.out.println("Side");
int s=sc.nextInt();
int v=s*s*s;
System.out.println("Volume of cube="+v);
break;
case 2:
System.out.println("Radius");
int r=sc.nextInt();
double v1= (4/3)*(22/7)*r*r*r;
System.out.println("Volume of sphere="+v1);
break;
case 3:
System.out.println("Enter Length");
int l=sc.nextInt();
System.out.println("Enter breadth");
int b=sc.nextInt();
System.out.println("Enter Height");
int h=sc.nextInt();
int v2=l*b*h;
System.out.println("Volume of cuboid="+v2);
break;
default :
System.out.println("Wrong input");
}
}
}
Please Subscribe to My Youtube Channel Study To Study ICSE-Swapnil Mehta for more Java Programs
Explanation:
Hope this will help you
Please mark me as brainlist :)
Thank you Have a nice day :)