diff --git a/src/main/java/src/TasksFrame.java b/src/main/java/src/TasksFrame.java index 67b7952..406a8e9 100644 --- a/src/main/java/src/TasksFrame.java +++ b/src/main/java/src/TasksFrame.java @@ -89,6 +89,8 @@ public class TasksFrame extends JFrame { setupRoundSum(); + setupExponent(); + setupUmrechnen(); setupBmi(); @@ -96,6 +98,67 @@ public class TasksFrame extends JFrame { + } + + private void setupExponent() { + + JPanel jPanel = setupPanel("Potenzrechner"); + JButton button = new JButton("calculate"); + button.setVisible(true); + button.setBounds(10, 65, 100, 30); + button.setForeground(Color.WHITE); + button.setBackground(Color.BLUE); + + JLabel height = new JLabel("basis"); + height.setVisible(true); + height.setBounds(10, 20, 60, 30); + + JTextField jTextField = new JTextField(); + jTextField.setVisible(true); + jTextField.setBounds( 10, 45, 30, 20); + jTextField.setFont(new java.awt.Font("Arial", Font.BOLD, 12)); + + + JLabel weight = new JLabel("exponent"); + weight.setVisible(true); + weight.setBounds(80, 20, 60, 30); + + JTextField textField = new JTextField(); + textField.setVisible(true); + textField.setBounds( 80, 45, 30, 20); + textField.setFont(new java.awt.Font("Arial", Font.BOLD, 12)); + + JLabel jLabel = new JLabel(); + jLabel.setVisible(true); + jLabel.setBounds(10, 90, 150, 30); + + + jPanel.add(button); + jPanel.add(jTextField); + jPanel.add(height); + jPanel.add(weight); + jPanel.add(textField); + jPanel.add(jLabel); + + button.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + String text = jTextField.getText(); + String text1 = textField.getText(); + double val = Double.valueOf(text); + double val1 = Double.valueOf(text1); + double res = Double.valueOf(expo(val, val1)); + jLabel.setText(String.valueOf(res)); + } + }); + + + } + + public double expo(double base, double exp) { + + double result = Math.pow(base, exp) ; + return result; } private void setupDate() {