Write a program using switch case to find the volume of a cube, a sphere and a cuboid. For an incorrect choice, an appropriate error message should be displayed. i. Volume of a cube=s*s*s; ii. Volume of a sphere=4/3π*r*r*r; iii. Volume of a cuboid=l*b*h;
Answers
Answer:
SOLUTION OF THE PROGRAM
import java util.*;
import java util.*;public class switch
import java util.*;public class switch {
import java util.*;public class switch {public static void main (string args [])
import java util.*;public class switch {public static void main (string args []) {
import java util.*;public class switch {public static void main (string args []) {int sw , vsphere = 0 , vcube = 0 , vcuboid = 0 , s , pi , r , l , b , h ;
import java util.*;public class switch {public static void main (string args []) {int sw , vsphere = 0 , vcube = 0 , vcuboid = 0 , s , pi , r , l , b , h ; Scanner sc = new scanner (system.in) ;
import java util.*;public class switch {public static void main (string args []) {int sw , vsphere = 0 , vcube = 0 , vcuboid = 0 , s , pi , r , l , b , h ; Scanner sc = new scanner (system.in) ;System.out.println ("Enter the side of cube") ;
import java util.*;public class switch {public static void main (string args []) {int sw , vsphere = 0 , vcube = 0 , vcuboid = 0 , s , pi , r , l , b , h ; Scanner sc = new scanner (system.in) ;System.out.println ("Enter the side of cube") ; s = sc.nextInt();
System.out.println ("Enter the radius of sphere");
r = sc.nextInt();
System.out.println ("Enter the value of pie " + "π" ) ;
pi = sc.nextInt();
System.out.println ("Enter the value of length of cuboid") ;
l = sc.nextInt();
System.out.println ("Enter the value of breadth of cuboid") ;
b = sc.nextInt();
System.out.println ("Enter the height of cuboid");
h = sc.nextInt();
vsphere = 4/3*pi*r*r*r ;
vcube = s*s*s ;
vcuboid = l*b*h ;
System.out.println ("Volume of sphere =" + vsphere);
System.out.println ("Volume of cuboid =" + vcuboid);
System.out.println ("Volume of cube =" + vcube);
}
}