+ 1
how to write a java program to find the area of a circle ?
6 ответов
+ 3
import java.util.Scanner;
public class Area {
public static void main(String[] args) {
int r;
double pi = 3.14, area;
Scanner s = new Scanner(System.in); System.out.print("Enter radius of circle:");
r = s.nextInt();
area = pi * r * r; System.out.println("Area of circle:"+area);
}
}
Leave likes if I helped :)
+ 1
if radius is the input.....then define a function (A =3.414*r*r)
+ 1
public class CalculateCircleAreaExample {
public static void main(String[] args) {
int radius = 3;
System.out.println("The radius of the circle is " + radius);
/*
* Area of a circle is pi * r * r where r is a radius of a circle.
*/
// NOTE : use Math.PI constant to get value of pi
double area = Math.PI * radius * radius;
System.out.println("Area of a circle is " + area);
}
}
OUTPUT
The radius of the circle is 3
Area of a circle is 28.274333882308138
0
I wouldnt have written a complete code answer. There is no learning process if you just give the whole code. He/she could have googled for that too and soloLearn is about learning :p
0
Ok .
- 2
if you know the radious of the circle use this.
class Area
{
public static void main(String[] args)
{
double A;
int r=3;
double pi=3.14;
A=((pi)*(r*r));
System.out.println("Area of the circle is :"+A);
}
}
r is the radious of the circle and it is in meters if u want cm then first you have to convert that meters into your required format.