-
Notifications
You must be signed in to change notification settings - Fork 0
/
Controller.java
52 lines (38 loc) · 1.64 KB
/
Controller.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
package momentOfInertia;
import javafx.scene.control.Button;
import javafx.scene.control.TextField;
public class Controller {
public TextField txtMass;
public TextField txtLoad;
public TextField txtAxle;
public TextField txtNOne;
public TextField txtNTwo;
public TextField txtSec;
public TextField txtResultMoment;
public TextField txtResultAngular;
public Button btnCalcMoment;
public Button btnRefresh;
public void calculateResult(){
double mass = Double.parseDouble(txtMass.getText());
double heightOfLoad = Double.parseDouble(txtLoad.getText());
double radiusOfAxle = Double.parseDouble(txtAxle.getText());
double valueOfN1 = Double.parseDouble(txtNOne.getText());
double valueOfN2 = Double.parseDouble(txtNTwo.getText());
double time = Double.parseDouble(txtSec.getText());
double gravityValue = 9.8;
double angularVelocity = ((4 * 3.1416 * valueOfN2) / time);
double momentOfInertia = ((2 * mass * gravityValue * heightOfLoad) - (mass * Math.pow(radiusOfAxle, 2) * Math.pow(angularVelocity, 2))) / (Math.pow(angularVelocity, 2) * (1 + (valueOfN1 / valueOfN2)));
txtResultAngular.setText(Double.toString(angularVelocity));
txtResultMoment.setText(Double.toString(momentOfInertia));
}
public void refresh() {
txtMass.setText("");
txtLoad.setText("");
txtAxle.setText("");
txtNOne.setText("");
txtNTwo.setText("");
txtSec.setText("");
txtResultMoment.setText("");
txtResultAngular.setText("");
}
}