- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRed.java
More file actions
Latest commit
117 lines (98 loc) · 3.12 KB
/
Copy pathRed.java
File metadata and controls
117 lines (98 loc) · 3.12 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
//This file does not compile with the project
//SEPERATE
importjavax.swing.JOptionPane;
importjavax.swing.JPanel;
importjavax.swing.JTextArea;
importjavax.swing.JTextField;
importjava.awt.*;
importjava.text.NumberFormat;
importjava.io.IOException;
importjavax.swing.Box;
importjavax.swing.JFileChooser;
importjavax.swing.JFrame;
importjavax.swing.JLabel;
publicclassRed {
publicstaticMenuframe;
publicstaticJTextAreana;
publicstaticvoidmain(String[] args) {
frame = newMenu("Final Lab"); // change the format of the menu pane
//set the font and format
na = newJTextArea(10,50);
na.setFont(newFont("Monospaced",Font.PLAIN, 12));
frame.getContentPane().add(na);
frame.pack();
frame.setVisible(true);
}
publicstaticvoidquadSolver() {
doubleA = 0, B = 0, C = 0, answer1 = 0, answer2 = 0;
JPanelD = newJPanel();
JTextFielda = newJTextField(10);
JTextFieldb = newJTextField(10);
JTextFieldc = newJTextField(10);
D.add(newJLabel("A = "));
D.add(a);
D.add(Box.createHorizontalStrut(15)); // a spacer
D.add(newJLabel("B = "));
D.add(b);
D.add(Box.createHorizontalStrut(15)); // a spacer
D.add(newJLabel("C = "));
D.add(c);
D.setPreferredSize(newDimension(550, 200));
JOptionPane.showConfirmDialog(null, D, "Quadratic", JOptionPane.OK_CANCEL_OPTION);
if (a.getText().equals(""))
A = 0;
else
A = Double.parseDouble(a.getText());
if (b.getText().equals(""))
B = 0;
else
B = Double.parseDouble(b.getText());
if (c.getText().equals(""))
C = 0;
else
C = Double.parseDouble(c.getText());
answer1 = (-B + Math.sqrt((B * B) - (4 * A * C))) / (2 * A);
answer2 = (-B - Math.sqrt((B * B) - (4 * A * C))) / (2 * A);
Stringmessage = answer1 + " and " +answer2;
na.setText(message);
}
publicstaticvoidFacSolver() {
intfactorial = 0;
StringFac = JOptionPane.showInputDialog ("Enter the number ");
factorial = Integer.parseInt(Fac);
sum(factorial);
}
publicstaticvoidsum (intnum) {
doubleresult;
if (num == 1)
result = 1;
else
result = num + sum((num– 1));
Stringmessage = "Answer: " + result;
na.setText(message);
}
publicstaticvoidareaCirc() {
booleanpromptUser = true;
doublearea = 0;
do {
try {
Stringinitial = JOptionPane.showInputDialog ("Enter the radius of a circle ");
area = Double.parseDouble(initial);
promptUser = false;
} catch (NumberFormatExceptionn) {
System.out.println("Don't do that");
}
} while (promptUser);
Stringmessage = "The area of the circle is ";
message += area;
na.setText(message);
}
publicstaticvoidLookup() {
Stringmessage = "Lookup chemical element selected";
na.setText(message);
}
publicstaticvoidVelocity() {
Stringmessage = "Calcualte exit velocity selected";
na.setText(message);
}
}