Skip to content

Instantly share code, notes, and snippets.

@Nick-Harvey
Created January 2, 2014 15:09
Show Gist options
  • Save Nick-Harvey/8220591 to your computer and use it in GitHub Desktop.
Save Nick-Harvey/8220591 to your computer and use it in GitHub Desktop.
First Java App
import java.util.Scanner;
public class MyFirstClass {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
double PI=3.14;
double radius, area, circumference;
System.out.print("Enter the radius: ");
radius = sc.nextDouble();
//Calculate the area
area = PI * radius * radius;
//Calculate the circumference
circumference = 2 * PI * radius;
//Print the area and the circumference of the circle
System.out.println("The area is "+area);
System.out.println("The Circumference is "+ circumference);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment