-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCircle.java
More file actions
36 lines (27 loc) · 1.31 KB
/
Circle.java
File metadata and controls
36 lines (27 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import java.util.Scanner;
public class Circle {
/*****************************************************
Filename: Circle
Created by: Melissa B.
Created on: 01 March 2017
Comment: Work out values of a circle with user input as radius
******************************************************/
public static void main(String[] args)
{
// Declaring Variables
final double PI = 3.141592653589793;
double radius, area, circumference, diameter;
Scanner input = new Scanner(System.in); // Create an instance of the Scanner Class
System.out.println("Enter radius of circle:"); // Print message to screen
radius = input.nextDouble(); // Ask for input and store into radius int
System.out.println(""); // Skip two lines
System.out.println("---- Your Circle ----");
area = PI * (radius * radius); // Work out area using constant value and input value
System.out.println("Area: " + area); // Print area to screen
circumference = 2 * PI * radius;
System.out.println("C: " + circumference); // Print circumference to screen
diameter = 2 * radius;
System.out.println("d: " + diameter);
System.out.println("\n"); // Skip two lines
}
}