Computer Science, asked by yashchouhan005, 5 months ago

write a program in java to calculate the area of a sphere and a cylinder​

Answers

Answered by AnshumanRai9910
34

Answer:

>> Surface Area of sphere

class TotalSurfaceAreaOfSphere1  

{

     

  public static void main(String args[])  

   {    

       

 

             

           double r=Double.parseDouble(args[0]);

     

    double  area=(4*22*r*r)/(7);

 

           System.out.println("Total SurfaceArea Of sphere is:" +area);

       

 

       

         

  }

}

>> Cylinder

mport java.util.Scanner;

class VolumeOfCylinder  

{

  public static void main(String args[])  

   {    

       

     Scanner s= new Scanner(System.in);

       

        System.out.println("Enter the radius:");

        double r=s.nextDouble();

        System.out.println("Enter the height:");

        double h=s.nextDouble();

 

           double  volume=((22*r*r*h)/7);

 

           System.out.println("volume of Cylinder is: " +volume);

       

 

       

         

  }

}

Now chill....

Similar questions