write a program in java to calculate volume of a sphere whose radius is 7.5 cm.
Answers
Answered by
2
Program:
import java.io.*;
public class Main{
public static void main(String args[]){
System.out.println("Volume of sphere when radius is 7.5cm is : "+((4/3) x 3.14 x 7.5 x 7.5 x 7.5)+"cm.");
}
}
Output:
Volume of sphere when radius is 7.5cm is : 1324.6875cm.
Explanation:
- volume of sphere 4/3 πr³
- so i calculated (4/3) x 3.14 x 7.5 x 7.5 x 7.5
- and printed the value directly
- so it make less lines
- and it will allocates less space when compared to initializing variables and passing values to them
----- Hope this helps
Similar questions