- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomputer_programming.java
More file actions
Latest commit
32 lines (25 loc) · 1000 Bytes
/
Copy pathcomputer_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
importjava.util.*;
importjava.io.BufferedReader;
importjava.io.IOException;
importjava.io.InputStreamReader;
publicclasscomputer_programming{
publicstaticvoidmain(String[] args) {
/*hello there */
intradius=0;
System.out.println("Please enter radius of a circle");
try{
BufferedReaderbr = newBufferedReader(newInputStreamReader(System.in));
radius = Integer.parseInt(br.readLine());
}catch(NumberFormatExceptionne){
System.out.println("Sorry, invalid number"+ne);
System.exit(0);
}catch(IOExceptionioe){
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
doublearea = Math.PI * radius * radius;
System.out.println("the area = "+ area);
}
}