-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFirstEquationOfMotion.java
More file actions
74 lines (74 loc) · 3.33 KB
/
FirstEquationOfMotion.java
File metadata and controls
74 lines (74 loc) · 3.33 KB
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 FirstEquationOfMotion{
public static void main(String[]args)throws InterruptedException{
Scanner sc = new Scanner(System.in);
double v,u,a,t;
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, [T]=Time, [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 Time (t): ");
t = sc.nextDouble();
System.out.println("--------------------------------------------------");
System.out.println("Now,\nusing, v=u+at\n=>v="+u+"+"+a+"*"+t);
v = u+a*t;
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 Time (t): ");
t = sc.nextDouble();
System.out.println("--------------------------------------------------");
System.out.println("Now,\nusing, v=u+at\n=>u=v-at\nu="+v+"-"+a+"*"+t);
u = v-a*t;
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 Time (t): ");
t = sc.nextDouble();
System.out.println("--------------------------------------------------");
System.out.println("Now,\nusing, v=u+at\n=>a=v-u/t\na="+v+"-"+u+"/"+t);
a=(v-u)/t;
System.out.println("a= "+a+" m/s²");
}
else if(imp=='T'||imp=='t'){
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, v=u+at\n=>t=v-u/a\nt="+v+"-"+u+"/"+a);
t=(v-u)/a;
System.out.println("t= "+t+" s");
}
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");
}
}
}
}