write a java program to calculate area of circle where area =22/7×r² and radius is entered at run time
Answers
Answer:
\qquad\quad\mathcal{\underline{\underline{ANSWER}}}
ANSWER
import java.util.*;
public class Brainly
{
\quad public static void main (String args[])
\quad \; {
\quad \; Scanner sc= new Scanner (System.in);
\quad \; System.out.println("enter area of circle");
\quad \; double area = sc.nextDouble( );
\quad \; double radius = Math.sqrt(7 * area/22);
\quad \; System.out.println("Radius of circle =" + radius);
\quad }
}
___________________________
I've taken 154 as input while executing the program and received the correct output.
Answer:
import java.util.Scanner;
class Area
{
public static void main(String[] args) {
float r;
float area;
float pi = 22/7f;
Scanner scanner = new Scanner(System.in);
System.out.println("What is the radius of the circle?");
r = scanner.nextFloat();
area = pi*r*r;
System.out.println("Area of the circle is" + " " + area);
}
}
Explanation:
execute the program and you can input radius and the area will be displayed : )