This program asks the user for the radius and then calculates the circumference of a circle (2*pi*r) using the given radius.
My code
import java.util.Scanner;
public class Circumference {
public static void main(String[] args) {
Scanner reader = new Scanner(System.in);
// Program your solution here
System.out.println("Type the radius: ");
int radius = Integer.parseInt(reader.nextLine());
System.out.println("Circumference of the circle: " + (2 * Math.PI * radius));
}
}
Model code
import java.util.Scanner;
public class Circumference {
public static void main(String[] args) {
Scanner reader = new Scanner(System.in);
// Program your solution here
System.out.print("Type the radius: ");
int radius = Integer.parseInt(reader.nextLine());
System.out.println("");
System.out.println("Circumference of the circle: " + (2 * Math.PI * radius));
}
}