-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFallInWind.java
60 lines (48 loc) · 1.65 KB
/
FallInWind.java
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*Program to calculate the place where the object fall by taking the speed of the wind into consideration*/
import java.io.*;
public class FallInWind {
public static void main(String args[]) {
double x, y, x_speed, y_speed, x_initial_speed, x_wind_speed1;
double r;
double g;
g = -9.80665;
x = 0;
y = 100000;
x_initial_speed = 800;
x_speed = x_initial_speed;
y_speed = 0;
r = 100000;
String buf;
try{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter Wind Speed: ");
buf = br.readLine();
x_wind_speed1 = Double.parseDouble(buf);
while(y>=0) {
y_speed += g/r;
if( y > 8000 ) {
x_speed = x_initial_speed + x_wind_speed1;
} else {
x_speed = x_initial_speed;
}
x += x_speed/r;
y += y_speed/r;
}
int aX = (int)x;
int bX = aX%100;
if(bX<=50){
aX = aX - bX;
}
else{
bX=100-bX;
aX=aX+bX;
}
System.out.print("estimated distance = "+x+"\n");
System.out.print("estimated distance is approximately : "+aX+"\n");
}catch(Exception e)
{
System.out.print("Error:"+e);
}
return;
}
}