Computer Science, asked by mahibisht01, 1 year ago

write a program in java to calculate volume of a sphere whose radius is 7.5 cm.​

Answers

Answered by rakeshchennupati143
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:

  1. volume of sphere 4/3 πr³
  2. so i calculated (4/3) x 3.14 x 7.5 x 7.5 x 7.5
  3. and printed the value directly
  4. so it make less lines
  5. and it will allocates less space when compared to initializing variables and passing values to them

----- Hope this helps

Similar questions