1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
/* Calculate Circle Area using Java Example This Calculate Circle Area using Java Example shows how to calculate area of circle using it's radius. */ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class CalculateCircleAreaExample { public static void main(String[] args) { int radius = 0; System.out.println("Please enter radius of a circle"); try { //get the radius from console BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); radius = Integer.parseInt(br.readLine()); } //if invalid value was entered catch(NumberFormatException ne) { System.out.println("Invalid radius value" + ne); System.exit(0); } catch(IOException ioe) { System.out.println("IO Error :" + ioe); System.exit(0); } /* * 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 of Calculate Circle Area using Java Example would be Please enter radius of a circle 19 Area of a circle is 1134.1149479459152 */ |
its need for try and catch block that means numberformat exception
very helpful thanks!!!!!!!!!!!!!!!!!!1
its very helpful programs to all
Thanks……………..
great examples … thnx
baguih la….teruskan…
karthik please help me I am not getting
thanks. This is the first sample project I checked so far
This is very useful to all who wanted to study java
i need to know more of the same
i need without try catch block
Thank you very much!
thallipoli site 😀
kure programs idamo..padikkana 🙂
thanks
this program is very helpfull and very neccessary 4 programming
i am a begginer sir , can any of u tell me where will i get the compiler to right java programs
download netbean 😉 IDE latest version
guys just tell me where will i get a basic java compiler to write java preograms
eclipse. you’d better to search a youtube or google article to teach you step by step to install them. don’t forget to use the newest version of java development kit and eclipse.
i am a fresher …….
no use of ecception here
<html>
<head>
<script>
function sum() {
var celsuis=document.getElementById(“celsuis”).value;
var A= document.getElementById(“number”).value=celsuis*9/5+32;
}
</script>
</head>
<body>
Celsuis<input type=”text” id=”celsuis”>
Fahrenheit<input type=”text” id=”number”>
<input type=”button” value=”convert” onclick=”sum()”/>
</body>
</html>
simply copy it and save it as .html ….open in your browser….
Akshay hopefully you know this by now, as it has been 10 months since you posted, but that is Javascript. Not Java, which despite sharing a common name are very different from on another.
These Programs Are Very Useful For Java Beginners!… Thanks!…
To calculate the Area Of Circle , The Little more Simple Program is :
import java.io.*;
class Circle
{
public static void main(String ar[])
{
Console con = System.console();
int radius;
System.out.println(“Enter the radius of the circle: “);
radius = Integer.parseInt(con.readLine());
double area = 3.14* radius* radius;
System.out.println(“The area of circle is :” + area);
}
}
import java.util.*;
class area
{
static Scanner sc=new Scanner(System.in);
final static float c=3.14f;
public static void main(String args [])
{
System.out.println(“enter the value of radius “);
int r=sc.nextInt();
float area=c*r*r;
System.out.println(“the are of circlle with radius”+r+”is “+area);
}
}
Am I wrong??
import java.lang.*;
import java.util.*;
class Circle
{
public static void main(String[] args)
{
double pi = 3.14;
Scanner s = new Scanner(System.in);
System.out.println(“Enter the radius”);
double r = s.nextDouble();
double A=pi*r*r;
System.out.println(“Area of Circle is: “+A);
}
}
import java.util.*;
public class Circle_Area
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
double pi = 3.14;
System.out.println(“Enter the radius of the circle”);
double a = sc.nextDouble();
double area = pi*a*a;
System.out.println(“The area of the circle is “+area);
}
}