forked from LaunchCodeEducation/java-exercises
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArea.java
More file actions
25 lines (23 loc) · 698 Bytes
/
Copy pathArea.java
File metadata and controls
25 lines (23 loc) · 698 Bytes
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
package org.launchcode.java.studios;
import java.util.Scanner;
/**
* Created by melocal on 2/28/17.
*/
public class Area {
public static void main(String[] args) {
double PI = 3.14;
double r;
double area;
Scanner in = new Scanner(System.in);
do{
System.out.println("Enter a positve number for radius: ");
while (!in.hasNextDouble()){
System.out.println("Enter a positive number for radius: ");
in.next();
}
r = in.nextDouble();
} while (r <= 0);
area = PI * r * r;
System.out.println("The radius of a circle of radius " + r + "is: " + area);
}
}