WAP to input radius of a circle and print area of circle
today is my exam
Answers
Answered by
3
Program :
InputStreamReader Method
import java.io.*;
public class Area
{
public static void main ()throws IOException
{
InputStreamReader isr = new InputStreamReader (System.in);
BufferedReader br = new BufferedReader (isr);
double ar, rad;
System.out.println("Enter the radius of the circle : ");
rad = Double.readDouble(br.readLine());
ar = 22/7*rad*rad;
System.out.println("The Area of the Circle : "+ar);
}
}
Scanner Method
import java.util.*;
public class Area
{
public static void main ()
{
Scanner in = new Scanner (System.in);
double ar,rad;
System.out.println("Enter the radius of the circle : ");
rad = in.nextDouble();
ar = 22/7*rad*rad;
System.out.println("The Area of the circle : "+ar);
}
}
Similar questions