Question: How can I make sure that the variable radius is initialized before the for loop? public class SphereVolume { public static void main ( String
How can I make sure that the variable "radius" is initialized before the for loop?
public class SphereVolume
public static void mainString args
Scanner scan new ScannerSystemin;
double radius;
double singleVolume;
double totalVolume ;
System.out.printlnEnter the number of spheres";
int N scan.nextInt;
forint i ; i N; i
if radius
System.out.printlnEnter the radius of the sphere";
radius scan.nextDouble;
singleVolume MathPIMathpowradius;
totalVolume singleVolume;
else
System.out.printlnPlease enter a positive value";
System.out.printlnThe total volume of the spheres is totalVolume;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
