Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

Quest

ion9:

i
mpor tjava. uti
l.Scanner;
classPr ogr am9
{
publ icst aticv oidmai n(Str
ingar gs[]
)
{
Scannersc=newScanner( System.in);
i
ntl ,b,h,r,
v;
Sy stem. out .printl
n("
---
--
---
--
---
---
---
--
--
-"
);
Sy stem. out .printl
n("
1f orCuboi d");
Sy stem. out .printl
n("
2f orCy l
indar");
Sy stem. out .printl
n("
3f orCone" );
Sy stem. out .printl
n("
---
--
---
--
---
---
---
--
--
-"
);
Sy stem. out .print(
"Enteryourchoi ce:"
);
ch=sc. next I
nt();
swi tch( ch)
{
case1:
Sy stem. out .print(
"Enterthelengt h:
");
l
=sc. next I
nt();
Sy stem. out .print(
"Enterthebr eadth:"
);
b=sc. nextInt();
Sy stem. out .print(
"Enterthehei ght:
");
h=sc. nextInt();
v=l* b* h;
Sy stem. out .printl
n("
Vol ume:"+v);
case2:
Sy stem. out .print(
"Entertheradi us:
");
r=sc. next I
nt ()
;
Sy stem. out .print(
"Enterthehei ght:
");
h=sc. nextInt();
v=3. 14* r*r*h;
Sy stem. out .printl
n("
Vol ume:"+v);
case3:
Sy stem. out .print(
"Entertheradi us:
");
r=sc. next I
nt ()
;
Sy stem. out .print(
"Enterthehei ght:
");
h=sc. nextInt();
v=( 1/3) *3.14*r* r*
h;
Sy stem. out .printl
n("
Vol ume:"+v);
def aul t:
Sy stem. out .printl
n("
Invali
dchoi ce");
}
}
}

You might also like