+ 1

how to write a java program to find the area of a circle ?

2nd Nov 2016, 5:56 PM
Mia
Mia - avatar
6 Answers
+ 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 :)
2nd Nov 2016, 6:30 PM
DeJay Gaming
DeJay Gaming - avatar
+ 1
if radius is the input.....then define a function (A =3.414*r*r)
2nd Nov 2016, 6:30 PM
Tarun Saxena
Tarun Saxena - avatar
+ 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
3rd Nov 2016, 3:46 PM
â€«ÙŠÙˆŰłÙ Ű§Ù„ŰčÙ…Ű±ÙŠâ€Źâ€Ž
â€«ÙŠÙˆŰłÙ Ű§Ù„ŰčÙ…Ű±ÙŠâ€Źâ€Ž - avatar
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
2nd Nov 2016, 6:36 PM
Florian Schwarzer
0
Ok .
2nd Nov 2016, 6:37 PM
Ashok
Ashok - avatar
- 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.
2nd Nov 2016, 6:34 PM
Ashok
Ashok - avatar