-
Language
Java using BufferedReader
-
Description
Calculates the volume of a sphere having its radius
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import java.io.*;
public class VolumeOfASphere {
public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
double radius, volume;
System.out.print("Enter the value of radius: ");
radius = Double.parseDouble(in.readLine());
volume=4.0*Math.PI*radius*radius*radius/3.0;
System.out.println("Value of volume: " + volume);
in.close();
}
}
public class VolumeOfASphere {
public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
double radius, volume;
System.out.print("Enter the value of radius: ");
radius = Double.parseDouble(in.readLine());
volume=4.0*Math.PI*radius*radius*radius/3.0;
System.out.println("Value of volume: " + volume);
in.close();
}
}