-
Notifications
You must be signed in to change notification settings - Fork 0
/
ThirdEquationOfMotion.java
74 lines (74 loc) · 3.5 KB
/
ThirdEquationOfMotion.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import java.util.Scanner;
public class ThirdEquationOfMotion{
public static void main(String[]args)throws InterruptedException{
Scanner sc = new Scanner(System.in);
double v,u,a,s;
int k = 0;
System.out.println("----------TYPE and ENTER ; What you want to calculate?----------");
while(k==0){
System.out.println("[V]=Final Velocity, [U]=Initial Velocity, [A]=Acceleration, [S]=Distance, [E]=Exit");
char imp = sc.next().charAt(0);
if(imp=='V'||imp=='v'){
System.out.print("Enter Initital Velocity (u): ");
u = sc.nextDouble();
System.out.print("Enter Acceleration (a): ");
a = sc.nextDouble();
System.out.print("Enter Distance (s): ");
s = sc.nextDouble();
System.out.println("--------------------------------------------------");
System.out.println("Now,\nusing, v²=u²+2as\n=>v²="+u+"² + 2*"+a+"*"+s);
v = Math.sqrt(Math.pow(u,2)+2*a*s);
System.out.println("v= "+v+" m/s");
}
else if(imp=='U'||imp=='u'){
System.out.print("Enter Final Velocity (v): ");
v = sc.nextDouble();
System.out.print("Enter Acceleration (a): ");
a = sc.nextDouble();
System.out.print("Enter Distance (s): ");
s = sc.nextDouble();
System.out.println("--------------------------------------------------");
System.out.println("Now,\nusing, u²=v²-2as\nu²=>"+v+"² - 2*"+a+"*"+s);
u = Math.sqrt(Math.pow(v,2)-2*a*s);
System.out.println("u= "+u+" m/s");
}
else if(imp=='A'||imp=='a'){
System.out.print("Enter Final Velocity (v): ");
v = sc.nextDouble();
System.out.print("Enter Initial Velocity (u): ");
u = sc.nextDouble();
System.out.print("Enter Distance (s): ");
s = sc.nextDouble();
System.out.println("--------------------------------------------------");
System.out.println("Now,\nusing, a=(v²-u²)/2s\na=> ("+v+"² - "+u+"²)/("+2+"*"+s+")");
a=(Math.pow(v,2)-Math.pow(u,2))/(2*s);
System.out.println("a= "+a+" m/s²");
}
else if(imp=='S'||imp=='s'){
System.out.print("Enter Final Velocity (v): ");
v = sc.nextDouble();
System.out.print("Enter Initial Velocity (u): ");
u = sc.nextDouble();
System.out.print("Enter Acceleration (a): ");
a = sc.nextDouble();
System.out.println("--------------------------------------------------");
System.out.println("Now,\nusing, s=(v²-u²)/2a\ns=> ("+v+"² - "+u+"²)/("+2+"*"+a+")");
s=(Math.pow(v,2)-Math.pow(u,2))/(2*a);
System.out.println("s= "+s+" m");
}
else if(imp=='E'||imp=='e'){
System.out.println("Exiting.");
Thread.sleep(500);
System.out.println("Exiting..");
Thread.sleep(500);
System.out.println("Exiting...");
Thread.sleep(500);
System.out.println("DONE");
System.exit(0);
}
else{
System.out.println("You entered some wrong value");
}
}
}
}