Skip to content

Instantly share code, notes, and snippets.

@arielmagbanua
Last active September 16, 2021 08:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arielmagbanua/338ed74afb54bc392f07e457b2703243 to your computer and use it in GitHub Desktop.
Save arielmagbanua/338ed74afb54bc392f07e457b2703243 to your computer and use it in GitHub Desktop.
Circle

Circle

Write a Java program to print the area and perimeter of a circle.

Starter Code

public class App {
    public static void main(String[] args) throws Exception {
        // scanner
        Scanner scanner = new Scanner(System.in);

        // get the number radius

        // calculate the area
        // hint: area = pi * r^2

        // calculate the circumference / perimeter
        // hint: perimeter = 2 * pi * r

        scanner.close();
    }
}

Outputs

Enter radius: 7.5
Perimeter is = 47.12388980384689
Area is = 176.71458676442586
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment