└── Calculation of water volume /Calculation of water volume: -------------------------------------------------------------------------------- 1 | To calculate the volume of water, you can use the following Java program based on the provided sources. This program prompts the user for the width of the sphere in inches and then calculates the area in inches, area in feet, volume in inches, volume in feet, and gallons of water. 2 | 3 | ```java 4 | import java.util.Scanner; 5 | 6 | public class WaterVolumeCalculator { 7 | public static void main(String[] args) { 8 | Scanner input = new Scanner(System.in); 9 | System.out.print("Enter the width of the sphere in inches: "); 10 | double width = input.nextDouble(); 11 | double radius = width / 2; 12 | 13 | // Constants 14 | final double PI = 3.14159; 15 | final double GALLONS_CONVERSION = 7.48; 16 | 17 | // Calculations 18 | double areaInches = 4 * PI * Math.pow(radius, 2); 19 | double areaFeet = areaInches / 12; 20 | double volumeInches = (4 / 3) * PI * Math.pow(radius, 3); 21 | double volumeFeet = volumeInches / 1728; 22 | double gallonsWater = volumeFeet * GALLONS_CONVERSION; 23 | 24 | // Outputs 25 | System.out.println("\nCalculated Values:"); 26 | System.out.println("Area in Inches: " + areaInches); 27 | System.out.println("Area in Feet: " + areaFeet); 28 | System.out.println("Volume in Inches: " + volumeInches); 29 | System.out.println("Volume in Feet: " + volumeFeet); 30 | System.out.println("Gallons of Water: " + gallonsWater); 31 | } 32 | } 33 | ``` 34 | 35 | This program uses the formulas provided in the Stack Overflow post [source](https://stackoverflow.com/questions/46186185/calculating-volume-of-sphere-in-water-tower-calculator-program-java) and the Java programming examples from javatpoint [source](https://www.javatpoint.com/program-to-calculate-the-volume-of-the-sphere). It also includes the conversion from cubic feet to gallons, as explained in the Sciencing article [source](https://sciencing.com/how-to-calculate-water-volume-12193099.html). 36 | --------------------------------------------------------------------------------