KnowledgeBoat Logo

Computer Applications

You want to calculate the radius of a circle by using the formula:

Area = (22/7) * r2; where r = radius of a circle

Hence the radius can be calculated as:

r = √((7 * area) / 22)

Write a program in Java to calculate and display the radius of a circle by taking area as an input.

Java

Java Math Lib Methods

159 Likes

Answer

import java.util.Scanner;

public class KboatCircleRadius
{
    public static void main(String args[]) {
        Scanner in = new Scanner(System.in);
        System.out.print("Enter Area of Circle: ");
        double area = in.nextDouble();
        double r = Math.sqrt(7 * area / 22);
        System.out.print("Radius of Circle = " + r);
    }
}

Variable Description Table

Program Explanation

Output

BlueJ output of You want to calculate the radius of a circle by using the formula: Area = (22/7) * r 2 ; where r = radius of a circle Hence the radius can be calculated as: r = √((7 * area) / 22) Write a program in Java to calculate and display the radius of a circle by taking area as an input.

Answered By

64 Likes


Related Questions