Given sphereRadius and piVal, compute the volume of a sphere and assign sphereVolume with the result. Use (4.0 / 3.0) to perform floating-point division, instead of (4 / 3) which performs integer division.

Volume of sphere = (4.0 / 3.0) Ï r3 (Hint: r3 can be computed using *)
import java.util.Scanner;
public class SphereVolumeCalculator {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
double piVal = 3.14159;
double sphereVolume;
double sphereRadius;
sphereRadius = scnr.nextDouble();
*insert code*
System.out.println(sphereVolume);
}
}

Respuesta :

Answer:

The code to this question can be defined as follows:

sphereVolume = (4.0/3.0)*piVal*sphereRadius*sphereRadius*sphereRadius; // defining a double variable sphereVolume that calculate and hold its value

Explanation:

Please find the complete code in the attachment file.

In the code, a class "SphereVolumeCalculator" is declared, and inside the main method Three double variable "piVal,  sphereRadius, and sphereVolume" , in which "piVal" is used to hold a value, in the next step scanner class object is created for holding the "shereRadius" value and the sphereVolume is used for calculate and print its value.  

Ver imagen codiepienagoya
ACCESS MORE
EDU ACCESS