Method which returns area of circle

Method which returns area of circle

Need simple Java Method example that returns area of circle

View Answers

February 23, 2008 at 3:50 PM


Java Example Code

With the help of given Java code you can return the area of a circle and give the radius as a parameter.

import java.io.*;

public class AreaAndParameter
{
public static void main(String[] args)
{
double r=0;
try{
BufferedReader br1 = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter Radius of Circle : ");
r = Integer.parseInt(br1.readLine());
AreaAndParameter a = new AreaAndParameter();
double area = a.areaOfCircle(r);
System.out.println("Area of Circle : "+area);
double perimeter = a.perimeterOfCircle(r);
System.out.println("Perimeter of Circle : "+perimeter);

}
catch(Exception e){

System.out.println("Error : "+e);
}
}
public double areaOfCircle(double r){
double area = Math.PI*r*r;
return area;
}
public double perimeterOfCircle(double r){
double perimeter = 2*Math.PI*r;
return perimeter; }}









Related Tutorials/Questions & Answers:
Method which returns area of circle - Java Beginners
Method which returns area of circle  Need simple Java Method example that returns area of circle  Java Example CodeWith the help of given Java code you can return the area of a circle and give the radius
Example for a method in java which returns a class
Example for a method in java which returns a class  Hi, I want to create a 1 class,and declare some methods there.I need to method must returns a classname.when i call that particular method(which returns a class),how can i
Advertisements
area of a circle - Java Beginners
area of a circle  Write a class circle which consists of functions getdata() and area(), and also write a main program to create a circle object and to find the area by calling the function area () in circle class and display
How to calculate area of Circle
How to Calculate Area of Circle   ... of calculating  the area of circle. In this program you will be taught each and every... the area of circle. After that it return the area of circle, return the doubles type
BlueJ (area of circle)
BlueJ (area of circle)  How does one write a program to calculate the area of a circle in BlueJ? Note that the user will have to provide the radius.   A simple program to calculate the area of a circle. radius provided
Write a program to calculate area and perimeter of a circle
Write a program to calculate area and perimeter of a circle... example will teach you the method for preparing a program to calculate the area and perimeter of a circle. First of all name a class as "CircleArea"
Regarding method returns multiple values
Regarding method returns multiple values  Hi, 1)I have a requirement like,1 method returns multiple values.how to do that one. 2)can i use method, for example like getFile()[] in this way or not. plzzzzzzzzzzzzzzzzzz provide
Generic method that returns the biggest item in the list.
Generic method that returns the biggest item in the list.  class EngineerProject{ String engrName; double totalBudgets; String department... } } Write a generic method that returns the biggest item in the list. Each
Circle question - Java Beginners
includes a static method createCircle() that o reads a radius of a circle from the user o creates a circle object, and o returns the object. ? The program creates a circle object by using the above method. ? The program passes the circle
Which method is more efficient?
Which method is more efficient?  I'm faced with initializing a bunch of text fields in java. The problem is that the number of text fields is quite large, so i thought of putting them into an array and using a loop to initialize
circle
circle  Program to test whether a given point lies inside a circle... of the circle : "); double r = input.nextDouble... of circle : "); double x1 = input.nextDouble(); System.out.print
Java method final parameter
. In the example the radius parameter for calculating the area of circle have been... which the calculation part of the program is coded.  Now in the main method...;of Circle= "+area); } public static void main(String
Creating circle inside a circle
Creating circle inside a circle  hi can any one give code for following output by awt/swing creating circle inside a circle ,outside cirlce and intersect a circle
Java Circle to Circle collision detection
Java Circle to Circle collision detection  Java Circle to Circle collision detection
How to found which class or method contain specific annotation?
How to found which class or method contain specific annotation?  ... and execute that method or class which ever is possible... which class is using @one annotation and which @Two? OR We are having a class
could you suggest me that in which area i have to do a project?i want a complete guidence to complete my project.
could you suggest me that in which area i have to do a project?i want a complete guidence to complete my project.  could you suggest me that in which area i have to do a project?i want a complete guidence to complete my project
method overriding in java
method overriding in java  program to compute area of square,rectangle,triangle,circle and volume of sphere,cylinder and perimeter of a cube using method overriding
method overriding in java
method overriding in java  program to compute area of square,rectangle,triangle,circle and volume of sphere,cylinder and perimeter of a cube using method overriding
JavaScript Math.sin() method
JavaScript Math.sin() method       JavaScript's Math.sin() method returns mathematical sine... have created an input box into which user can input the values for sin() method
Clip Area
the rectangular area. The method setClip() sets the clipping area to clip the shape. ... Clip Area       This section illustrates you how to show the clipping of Area. A Clip
JavaScript getFullYear method
JavaScript getFullYear method       JavaScript method getFullYear() returns present year. To illustrate getFullYear() method here we have created a button in the HTML page when you
Java GUI code- creating a circle
that prompts the user to enter the center and a point on the circle, which is (x,y)(x2,y2). The program should then output the circle's radius, circumference, and area. I did my code but I can't seem to figure out the mathematical code
JavaScript parentElement method
JavaScript parentElement method       JavaScript's parentElement() method returns reference to the parent element of the specified element. By using the parentElement() method we can
How to change the value of a variable which is set in jsp (by jstl method) by calling the function from js?
How to change the value of a variable which is set in jsp (by jstl method... which is set in jsp (by jstl method) by calling the function from js? I set the value in jsp by using jstl method for eg:'<'c:set var="name1" value="Add User
JavaScript getAdjacentText method
JavaScript getAdjacentText method       JavaScript getAdjacentText method returns... written some text paragraph and the text on which we want to apply the method
What is the equivalent method in Java which is equivalent to clrscr() in c/c++ . The code should help to clear the output screen ?
What is the equivalent method in Java which is equivalent to clrscr() in c/c... have searched the net to know that is there any equivalent method for clrscr() which is used in c/c++. In some sites i found using the Runtime.xxxx.xxx(command
ModuleNotFoundError: No module named 'circle'
ModuleNotFoundError: No module named 'circle'  Hi, My Python... 'circle' How to remove the ModuleNotFoundError: No module named 'circle'... to install padas library. You can install circle python with following command
ModuleNotFoundError: No module named 'circle'
ModuleNotFoundError: No module named 'circle'  Hi, My Python... 'circle' How to remove the ModuleNotFoundError: No module named 'circle'... to install padas library. You can install circle python with following command
ModuleNotFoundError: No module named 'circle'
ModuleNotFoundError: No module named 'circle'  Hi, My Python... 'circle' How to remove the ModuleNotFoundError: No module named 'circle'... to install padas library. You can install circle python with following command
JavaScript method cos()
JavaScript method cos()       This section illustrates you the use of JavaScript method cos(). The method cos() returns the cosine of the specified number. It returns the numeric value
Given a list of scenarios, identify which will result in an ejbRemove method not being called on a bean instance.
of scenarios, identify which will result in an ejbRemove method not being... Given a list of scenarios, identify which will result in an ejbRemove method not being called on a bean instance. Prev Chapter 4
How to calculate area of rectangle
to define one rectangle method which takes two parameters of type integer. To calculate the area of the rectangle define one method calculate which will calculate the area of the rectangle. Now inside the main method create object of class
Text Area
Text Area  how to browse an image in text area instead of giving url of particular image
Java bigdecimal subtract method example
class subtract method. Method returns bigdecimal object values as per context settings. This bigdecimal class method subtracts the object value( in which... Java bigdecimal subtract method example   
JavaScript test() method
JavaScript test() method       In this section, you will study the use of test() method. The test() method returns true if a pattern exists within a string, otherwise it returns
JavaScript method atan()
JavaScript method atan()       This section illustrates you the use of JavaScript method atan(). The atan() method returns the arc tangent of a specified number as a numeric value
ModuleNotFoundError: No module named 'returns'
ModuleNotFoundError: No module named 'returns'  Hi, My Python... 'returns' How to remove the ModuleNotFoundError: No module named 'returns... to install padas library. You can install returns python with following command
How do I handle the reaction of a circle and a semi-circle colliding in java?
How do I handle the reaction of a circle and a semi-circle colliding in java?  How do I handle the reaction of a circle and a semi-circle colliding in java
isequaltostring returns false
isequaltostring returns false  Is "isequaltostring" returns false? How can we set the "isequaltostring nil"?? Please answer. Thanks in advance
JavaScript method fromCharCode()
fromCharCode(). The fromCharCode() method returns a readable string from the specified.... In the given example, we have used this method which translate the specified... JavaScript method fromCharCode()     
How to calculate area of triangle
variable. To calculate the area of triangle define the method triangle which... Area of Triangle       In this section we will learn how to calculate area of triangle. We
How to draw a circle bucket, draw a circle bucket, circle bucket
How to draw a circle bucket       This example has a simple way to learn easily to make a circle shape.... ADS_TO_REPLACE_2 Draw Circle: Now draw a circle inside the big circle with any
By using Applet display a circle in a rectangle
By using Applet display a circle in a rectangle  Write a java applet to display a circle in a rectangle
setting RGB for a circle
setting RGB for a circle  how can i change the color of the circle(not through filling it) and i want to use RGB (not regular colors such as black or red..) i should include RGB numbers (for example 240, 150, 19) but i am
Auto grow Text Area using jQuery plug-in
Auto grow Text Area using jQuery plug-in In this section, you will learn how to create a text area which auto grow on increment of the content using jQuery Plug-in. We fixed the height of text area to 70 pixels .The size of the window
Area Chart
the Area Chart by invoking the createAreaChart() method. This method is a static method of ChartFactory class and its returns the object of JFreeChart...; renderer.setSeriesPaint(0,Color.red); Above method is used set the color of the area
Java bigdecimal valueOf long method
valueOf method. Method returns bigdecimal values.  Method converts the long values in to bigdecimal value. Method returns a static bigdecimal object... Java bigdecimal valueOf long method   
Java bigdecimal remainder method example
working is demonstrated. Method returns a bigdecimal  value as per context settings. Method returns remainder i.e. this.object  % object specified... Java bigdecimal remainder method example  
method
method   how and where, we can define methods ? can u explain me with full programme and using comments
ModuleNotFoundError: No module named 'circle-asset'
ModuleNotFoundError: No module named 'circle-asset'  Hi, My Python... 'circle-asset' How to remove the ModuleNotFoundError: No module named 'circle-asset' error? Thanks   Hi, In your python

Ads