Array-promo

Question

Find the volume of a sphere

				
					Volume of Sphere=4/3 x 𝝿 x radius of sphere x radius of sphere
Enter radius of Sphere
3
3.142857142857143
Volume of the Sphere=28.285714285714285
				
			

Share code with your friends

Share on whatsapp
Share on facebook
Share on twitter
Share on telegram

Code

				
					import java.util.Scanner;
public class volumeOfSphere
{  
    public static void main(String args[])  
    {  
        Scanner sc=new Scanner(System.in);
        System.out.println("Enter radius of Sphere");
        double r=sc.nextDouble();
        double pi=(double)(22/7);  
        /*volume of Sphere= 4/3*pi*radius of sphere^2  */
        double volume=4/3*pi*(r*r);  
        System.out.println("Volume of the Sphere="+volume);  
    }  
} 

				
			

Coding Store

Leave a Reply

Your email address will not be published. Required fields are marked *