(Area and perimeter of a circle) Write a program that displays the area and perimeter of a circle that has a radius of 5.5 using the following formula:
perimeter = 2 * radius * π
area = radius * radius * π
Answer
/**
Program - 08
(Area and perimeter of a circle):
Write a program that displays the area and perimeter of a circle that has a radius of 5.5 using the following formula:
perimeter = 2 * radius * π
area = radius * radius * π
**/
public class HelloWorld
{
public static void main(String args[])
{
System.out.println("Perimeter = ");
System.out.println(2 * 5.5 * 3.14159);
System.out.println("Area = ");
System.out.println(5.5 * 5.5 * 3.14159);
}
}
OUTPUT
Perimeter =
34.55749
Area =
95.0330975
In this program the background knowledge which we have to acquire to solve this program is using:
1) Formula of Area = (length * breadth)
2) Formula of Perimeter = 2(length * breadth)
Note: As System.out.println(); is used, therefore the value of Area and Perimeter gets printed in the new line.
If you have any doubts or questions, please let me know.