0% found this document useful (0 votes)
23 views

Carl Joseph L. Mongolian Bt302 Elective

This document contains code to calculate the volumes of different geometric solids. It defines classes to calculate the volumes of cylinders, rectangular prisms, and spheres by taking radius, length, width, and height as inputs from the user. The main method uses a scanner to prompt the user to select a shape and enter the relevant dimensions. It then calls the appropriate volume calculation method and prints the result.

Uploaded by

Jai Mongolian
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

Carl Joseph L. Mongolian Bt302 Elective

This document contains code to calculate the volumes of different geometric solids. It defines classes to calculate the volumes of cylinders, rectangular prisms, and spheres by taking radius, length, width, and height as inputs from the user. The main method uses a scanner to prompt the user to select a shape and enter the relevant dimensions. It then calls the appropriate volume calculation method and prints the result.

Uploaded by

Jai Mongolian
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Carl Joseph L.

Mongolian BT302 ELECTIVE


package volumeofsolids;

import java.util.Scanner;

public class VolumeOfSolids {

double total;

static int a;

VolumeOfSolids( double rad , double hei){

total = ((22 * rad * rad * hei)/7);

VolumeOfSolids( double len , double hei,double wid){

total = (len * wid * hei);

VolumeOfSolids( double rad){

total = (4*22 * rad * rad *rad)/(3*7);

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

do{

System.out.println("");

System.out.println("Volume Of Solids");

System.out.println("1] Cylinder");

System.out.println("2] Rectangular");

System.out.println("3] Sphere");

System.out.println("4] Exit");

System.out.print("Please enter you choice: ");

a = sc.nextInt();

if (a == 1){

System.out.println("Cylinder");

System.out.print("Enter radius: ");

double r = sc.nextDouble();

System.out.print("Enter height: ");

double h = sc.nextDouble();
VolumeOfSolids v1 = new VolumeOfSolids(r,h);

System.out.print("Volume: " + v1.total);

}else if (a == 2 ){

System.out.println("Rectangular");

System.out.print("Enter length: ");

double l = sc.nextDouble();

System.out.print("Enter width: ");

double w = sc.nextDouble();

System.out.print("Enter height: ");

double h = sc.nextDouble();

VolumeOfSolids v2 = new VolumeOfSolids(l,w,h);

System.out.println("Volume: " + v2.total);

}else if ( a == 3){

System.out.println("Spehere");

System.out.print("Enter Radius: ");

double r = sc.nextDouble();

VolumeOfSolids v3 = new VolumeOfSolids(r);

System.out.print("Volume: " +v3.total);

}else {

System.exit(0);

}while(a!=4);

You might also like