computer project on The volume of solids,viz. cuboid, cylinder and cone can be calculated by the formula a) volume of a cuboid (v=l*b*h) b) volume of a cylinder (v=π*r2*h) c) volume of a cone (v=1 by 3*π*r2*h) using a switch case statement write a program to perform the above mentioned task.
Answers
Answered by
179
Heya user
Here is your answer !!
____________
import java.util.*;
public class Volume
{
public static void main ( String args [] )
{
Scanner in = new Scanner ( System.in ) ;
System.out.print ( " Enter your choice : " ) ;
int ch = in.nextInt();
double V ;
switch ( ch )
{
case 1 :
System.out.print ( " Enter the length , breadth and height : " ) ;
int l = in.nextInt();
int b = in.nextInt();
int h = in.nextInt();
V = l * b * h ;
System.out.println ( " Volume of cuboid : " + V ) ;
break ;
case 2 :
System.out.print ( " Enter the radius and height : " );
int r = in.nextInt();
int h = in.nextInt();
V = ( 22 / 7.0 ) * r * r * h ;
System.out.println ( " Volume of the cylinder : " + V ) ;
break ;
case 3 :
System.out.print ( " Enter the radius and height : " );
int r = in.nextInt();
int h = in.nextInt();
V = ( 22 / 7.0 ) * ( 1 / 3.0 ) * r * r * h ;
System.out.println ( " Volume of the cone : " + V ) ;
break ;
default :
System.out.println ( " Wrong choice " ) ;
}
}
}
____________
Hope it helps !!
Here is your answer !!
____________
import java.util.*;
public class Volume
{
public static void main ( String args [] )
{
Scanner in = new Scanner ( System.in ) ;
System.out.print ( " Enter your choice : " ) ;
int ch = in.nextInt();
double V ;
switch ( ch )
{
case 1 :
System.out.print ( " Enter the length , breadth and height : " ) ;
int l = in.nextInt();
int b = in.nextInt();
int h = in.nextInt();
V = l * b * h ;
System.out.println ( " Volume of cuboid : " + V ) ;
break ;
case 2 :
System.out.print ( " Enter the radius and height : " );
int r = in.nextInt();
int h = in.nextInt();
V = ( 22 / 7.0 ) * r * r * h ;
System.out.println ( " Volume of the cylinder : " + V ) ;
break ;
case 3 :
System.out.print ( " Enter the radius and height : " );
int r = in.nextInt();
int h = in.nextInt();
V = ( 22 / 7.0 ) * ( 1 / 3.0 ) * r * r * h ;
System.out.println ( " Volume of the cone : " + V ) ;
break ;
default :
System.out.println ( " Wrong choice " ) ;
}
}
}
____________
Hope it helps !!
Incredible29:
pls follow if u lyk my answer
Answered by
24
import java .io.*;
public class VolumeCalculator
{
int ch;
double v,l,b,h,r ;
double pi= 3.14 ;
InputStreamReader read = new InputStreamReader ( system.in);
BuffeedReader be=new BufferedReader (read);
public void calaulateVolume()throws IOException
{
after that from the picture
hope this will help u and please make it btainlist answer and please try to follow me...
public class VolumeCalculator
{
int ch;
double v,l,b,h,r ;
double pi= 3.14 ;
InputStreamReader read = new InputStreamReader ( system.in);
BuffeedReader be=new BufferedReader (read);
public void calaulateVolume()throws IOException
{
after that from the picture
hope this will help u and please make it btainlist answer and please try to follow me...
Attachments:
Similar questions