Uncategorized

Write a Java Program to define a function which accept a radius of Circle and calculate area

Write a Java Program to define a function which accept a radius of Circle and calculate area.

import java.io.*;
import java.util.*;

class Circle
{
  void area(int r)
  {
     double  ar = 3.14*r*r;
     System.out.println("Area of Circle = "+ ar);
  }
  public static void main(String args[ ])
  {
    Scanner sc = new Scanner (System.in); 
    int r;
    System.out.println("Enter radius = " );
    r = sc.nextInt( );
    Circle ob = new Circle( );
    ob.area( r );
  }
}
     

Click to comment

Leave a Reply

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

To Top