189k views
3 votes
4) Create a Java program that calculates the area and the

circumference of a circle given its radius. (Use Math.PI
to get the value of л.)

User Nayim
by
7.3k points

1 Answer

5 votes

Answer:

import java.util.Scanner;

public class Main {

public static void main(String[] args) {

double area;

double circumference;

double radius;

Scanner sc = new Scanner(System.in);

System.out.println("-------AREA AND CIRCUMFERENCE CALCULATOR-------");

System.out.print("Enter the radius value: ");

radius = sc.nextDouble();

area = Math.PI * Math.pow(radius, 2);

circumference = 2 * Math.PI * radius;

System.out.printf("\\The area of the circle is %.2f: ", area);

System.out.printf("\\The circumference of the circle is %.2f: ", circumference);

}

}

Step-by-step explanation:

User Mhrsalehi
by
6.7k points