-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomputer_programming.java
More file actions
32 lines (25 loc) · 1000 Bytes
/
computer_programming.java
File metadata and controls
32 lines (25 loc) · 1000 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
26
27
28
29
30
31
32
import java.util.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class computer_programming{
public static void main(String[] args) {
/*hello there */
int radius=0;
System.out.println("Please enter radius of a circle");
try{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
radius = Integer.parseInt(br.readLine());
}catch(NumberFormatException ne){
System.out.println("Sorry, invalid number"+ne);
System.exit(0);
}catch(IOException ioe){
System.out.println("IO Error"+ioe);
System.exit(0);
}
// we use Math.PI to get the value of 3.14
//circle area = PI*radius*radius
double area = Math.PI * radius * radius;
System.out.println("the area = "+ area);
}
}