Page 126 - ComputerScience_Class_11
P. 126
9 System.out.print("Enter side of a cube in cm : ");
10 s=sc.nextInt();
11 vc=s*s*s;
12 System.out.println("Volume of a cube : "+vc + " cu cm ");
13 System.out.println("-----------------------");
14 System.out.print("Enter radius of a sphere in cm : ");
15 r=sc.nextDouble();
16 vs=4.0/3.0 * 3.14 * r * r * r;
17 System.out.println("Volume of a sphere : "+vs + " cu cm ");
18 System.out.println("-----------------------");
19 System.out.print("Enter length of a cuboid in cm : ");
20 l=sc.nextInt();
21 System.out.print("Enter breadth of a cuboid in cm : ");
22 b=sc.nextInt();
23 System.out.print("Enter height of a cuboid in cm : ");
24 h=sc.nextInt();
25 vcd=l * b * h;
26 System.out.println("Volume of a cuboid : "+vcd + " cu cm ");
27 System.out.println("-----------------------");
28 }
29 }
The output of the preceding program is as follows:
BlueJ: Terminal Window - Java
Options
Enter side of a cube in cm : 10
Volume of a cube : 1000 cu cm
-----------------------
Enter radius of a sphere in cm : 52
Volume of a sphere : 588678.8266666667 cu cm
-----------------------
Enter length of a cuboid in cm : 25
Enter breadth of a cuboid in cm : 23
Enter height of a cuboid in cm : 15
Volume of a cuboid : 8625 cu cm
-----------------------
124 Touchpad Computer Science (Ver. 3.0)-XI

