Computer Science, asked by rjrahul85urw, 17 hours ago

write a program to accept radius from the user and calculate the area and circumference of a circle using library function​

Answers

Answered by atreyasamarth
0

Answer:

hope this helped

Explanation:

import java.math.*;

import java.util.*;  

class Circle

{

   double r;

   double circumference,area;

   void main()

   {

       Circle  cir = new Circle();

       Circle cir2 = new Circle();

       

       cir.accept();

       cir.compute();

       cir.display();

       

       cir2.accept();

       cir2.compute();

       cir2.display();

   }

   void accept()

   {

       System.out.println("please enter the value of the radius : ");

       Scanner sc = new Scanner(System.in);

       r = sc.nextDouble();

       

   }

   void compute()

   {

       area = Math.PI*Math.pow(r,2);

       circumference = 2*(Math.PI*r);

   }

   void display()

   {

       System.out.println("The area of the circle is :"+area);

       System.out.println("the circumference of the circle is :"+circumference);

   }

}

Similar questions