Question

Write a method that returns the area of a circle given the radius. Use the Math.PI...

Write a method that returns the area of a circle given the radius.

Use the Math.PI method.

Homework Answers

Answer #1
import java.util.Scanner;

public class AreaOfCircle {

    public static double getCircleArea(double radius) {
        return Math.PI * radius * radius;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.print("Enter radius of circle: ");
        double radius = in.nextDouble();
        System.out.println("Area of circle is " + getCircleArea(radius));
    }
}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
# given a radius, find the area of a circle def get_area_circle(r):        """        ...
# given a radius, find the area of a circle def get_area_circle(r):        """         what it takes             radius of a circle (any positive real number)         what it does:             computes the area of a circle             given a radius, find the area of a circle             area = pi*r2 (pi times r squared)         what it returns             area of a circle. Any positive real number (float)     """         # your code goes in...
Write a Python program to calculate the area of a circle. The user needs to input...
Write a Python program to calculate the area of a circle. The user needs to input the value of the radius of the circle. area = 3.14 x radius x radius You should use a function named circlearea to perform the calculation 3. Write a Python program to calculate the area of a square. The user needs to input the value of the length of the square. area = len*len You should use a function named squarearea to perform the...
In C programming, Thank you Write a program to compute the area of a circle. You...
In C programming, Thank you Write a program to compute the area of a circle. You have to write a complete “C” program that compiles and runs in Codeblocks. Program requirements: 1. Declare the variables needed: radius (r) and area (yourLastName). 2. Calculate and print the area of each circle. 3. The program MUST prompt the user for a new radius (r) over and over until the user types -1. 5. Use the type double for all decimal numbers. 6....
java Consider the following class definition: public class Circle { private double radius; public Circle (double...
java Consider the following class definition: public class Circle { private double radius; public Circle (double r) { radius = r ; } public double getArea(){ return Math.PI * radius * radius; } public double getRadius(){ return radius; } } a) Write a toString method for this class. The method should return a string containing the radius and area of the circle; For example “The area of a circle with radius 2.0 is 12.1.” b) Writeaequalsmethodforthisclass.ThemethodshouldacceptaCircleobjectasan argument. It should return...
Find the area of the largest trapezoid that can be inscribed in a circle of radius...
Find the area of the largest trapezoid that can be inscribed in a circle of radius 2 and whose base in as diameter of the circle.
Write a C# source code. Write a function called CircArea() that finds the area of a...
Write a C# source code. Write a function called CircArea() that finds the area of a circle. It should take an argument of type double and return an argument of the same type. Write a Main() method that gets a radius value from the user, calls CircArea(), and displays the result.
Compute the area of a circle with a radius =9 using the trapezoid rule . Select...
Compute the area of a circle with a radius =9 using the trapezoid rule . Select the number of trapezoids =4 . your answere below should be based on 4 trapezoids for half circle
Find the area of the shaded segment of a circle with radius 10 cm and central...
Find the area of the shaded segment of a circle with radius 10 cm and central angle of 30 degrees.
Find the radius of the curvature of the following curve at the given point. Then write...
Find the radius of the curvature of the following curve at the given point. Then write the equation of the circle of curvature at the point. The radius of curvature at a point P is given by 1/k, where k is the curvature at P y=ln 2x at x=1/2 The radius of curvature at x=1/2 is 1/k = ? The equation of the circle of curvature at this point is ?
radius of a circle r= 17cm Find AREA OF THE SECTOR WITH THE CENTRAL ANGLE 1°
radius of a circle r= 17cm Find AREA OF THE SECTOR WITH THE CENTRAL ANGLE 1°