-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPondRadius.java
More file actions
34 lines (30 loc) · 822 Bytes
/
Copy pathPondRadius.java
File metadata and controls
34 lines (30 loc) · 822 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
33
34
import java.io.IOException;
public class PondRadius {
public static void main(String[] args)
{
int fishCount = 20;
int fishLength = 10;
int lengthPerSqFt = 2;
double radius = 0.0;
int feet = 0;
int inches = 0;
double pondArea = (double)(fishCount*fishLength)/lengthPerSqFt;
radius = Math.sqrt(pondArea/Math.PI);
feet = (int)Math.floor(radius);
inches = (int)Math.round(12.0*(radius-feet));
System.out.println("To hold " + fishCount + " fish averaging " + fishLength +
" inches long you need a pond with an area of \n" +
pondArea + " square feet.");
System.out.println("The radius of a pond with area " + pondArea +
" square feet is " +
feet + " feet " + inches + " inches");
try
{
System.in.read();
}
catch (IOException e)
{
return;
}
}
}