Browse Source

new task "Durchschnitt" added

remotes/origin/develop
fdai6040 2 years ago
parent
commit
6254cee380
  1. 62
      src/main/java/src/TasksFrame.java

62
src/main/java/src/TasksFrame.java

@ -87,6 +87,8 @@ public class TasksFrame extends JFrame {
setupPI(100000);
setupDurchschnitt();
setupEulerschePhiFunk();
setupQuersumme();
@ -106,6 +108,66 @@ public class TasksFrame extends JFrame {
}
private void setupDurchschnitt() {
JPanel jPanel = setupPanel("Durchschnitt");
JButton button = new JButton("calculate");
button.setVisible(true);
button.setBounds(10, 65, 100, 30);
button.setBackground(Color.BLUE);
JTextField a = new JTextField();
a.setBounds(10, 40, 30, 20);
a.setVisible(true);
a.setFont(new java.awt.Font("Arial", Font.BOLD, 12));
JTextField b = new JTextField();
b.setBounds(50, 40, 30, 20);
b.setVisible(true);
b.setFont(new java.awt.Font("Arial", Font.BOLD, 12));
JTextField c = new JTextField();
c.setBounds(90, 40, 30, 20);
c.setVisible(true);
c.setFont(new java.awt.Font("Arial", Font.BOLD, 12));
JLabel jLabel = new JLabel();
jLabel.setVisible(true);
jLabel.setBounds(10,90,60,30);
jPanel.add(button);
jPanel.add(a);
jPanel.add(b);
jPanel.add(c);
jPanel.add(jLabel);
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String texta = a.getText();
String textb = b.getText();
String textc = c.getText();
Double val_a = Double.valueOf(texta);
Double val_b = Double.valueOf(textb);
Double val_c = Double.valueOf(textc);
double res = average(val_a, val_b, val_c);
jLabel.setText(String.valueOf(res));
}
});
}
public double average(double a, double b, double c) {
double sum = a + b + c;
double average = sum / 3;
double roundOff = Math.round(average * 100.0) / 100.0;
return roundOff;
}
private void setupExponent() {
JPanel jPanel = setupPanel("Potenzrechner");

Loading…
Cancel
Save