|
|
@ -102,11 +102,53 @@ public class TasksFrame extends JFrame { |
|
|
|
|
|
|
|
setupBmi(); |
|
|
|
|
|
|
|
setupReverse(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private void setupReverse() { |
|
|
|
|
|
|
|
JPanel jPanel = setupPanel("Text reverse"); |
|
|
|
|
|
|
|
JButton button = new JButton("reverse"); |
|
|
|
button.setVisible(true); |
|
|
|
button.setBounds(10, 65, 100, 30); |
|
|
|
button.setBackground(Color.BLUE); |
|
|
|
|
|
|
|
JTextField jTextField = new JTextField(); |
|
|
|
jTextField.setVisible(true); |
|
|
|
jTextField.setBounds( 10, 40, 150, 20); |
|
|
|
jTextField.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(jLabel); |
|
|
|
|
|
|
|
button.addActionListener(e -> { |
|
|
|
String text = jTextField.getText(); |
|
|
|
String res = reverse(text); |
|
|
|
jLabel.setText(res); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
private String reverse(String text) { |
|
|
|
StringBuilder reversed = new StringBuilder(); |
|
|
|
for (int i = text.length() - 1; i >= 0; i--) { |
|
|
|
reversed.append(text.charAt(i)); |
|
|
|
} |
|
|
|
return reversed.toString(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void setupKreisUmfang() { |
|
|
|
|
|
|
|
JPanel jPanel = setupPanel("Kreisumfang"); |
|
|
@ -136,8 +178,8 @@ public class TasksFrame extends JFrame { |
|
|
|
@Override |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
String text = jTextField.getText(); |
|
|
|
Double val = Double.valueOf(text); |
|
|
|
double res = Double.valueOf(kreisUmfang(val)); |
|
|
|
double val = Double.parseDouble(text); |
|
|
|
double res = kreisUmfang(val); |
|
|
|
jLabel.setText(String.valueOf(res)); |
|
|
|
} |
|
|
|
}); |
|
|
@ -146,8 +188,7 @@ public class TasksFrame extends JFrame { |
|
|
|
public double kreisUmfang(double radius) { |
|
|
|
|
|
|
|
double result = 2 * Math.PI * radius; |
|
|
|
double roundOff = Math.round(result * 100.0) / 100.0; |
|
|
|
return roundOff; |
|
|
|
return Math.round(result * 100.0) / 100.0; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -186,18 +227,15 @@ public class TasksFrame extends JFrame { |
|
|
|
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)); |
|
|
|
} |
|
|
|
button.addActionListener(e -> { |
|
|
|
String texta = a.getText(); |
|
|
|
String textb = b.getText(); |
|
|
|
String textc = c.getText(); |
|
|
|
double val_a = Double.parseDouble(texta); |
|
|
|
double val_b = Double.parseDouble(textb); |
|
|
|
double val_c = Double.parseDouble(textc); |
|
|
|
double res = average(val_a, val_b, val_c); |
|
|
|
jLabel.setText(String.valueOf(res)); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
@ -205,8 +243,7 @@ public class TasksFrame extends JFrame { |
|
|
|
|
|
|
|
double sum = a + b + c; |
|
|
|
double average = sum / 3; |
|
|
|
double roundOff = Math.round(average * 100.0) / 100.0; |
|
|
|
return roundOff; |
|
|
|
return Math.round(average * 100.0) / 100.0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
@ -251,16 +288,13 @@ public class TasksFrame extends JFrame { |
|
|
|
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)); |
|
|
|
} |
|
|
|
button.addActionListener(e -> { |
|
|
|
String text = jTextField.getText(); |
|
|
|
String text1 = textField.getText(); |
|
|
|
double val = Double.parseDouble(text); |
|
|
|
double val1 = Double.parseDouble(text1); |
|
|
|
double res = expo(val, val1); |
|
|
|
jLabel.setText(String.valueOf(res)); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
@ -268,8 +302,7 @@ public class TasksFrame extends JFrame { |
|
|
|
|
|
|
|
public double expo(double base, double exp) { |
|
|
|
|
|
|
|
double result = Math.pow(base, exp) ; |
|
|
|
return result; |
|
|
|
return Math.pow(base, exp); |
|
|
|
} |
|
|
|
|
|
|
|
private void setupDate() { |
|
|
@ -328,24 +361,20 @@ public class TasksFrame extends JFrame { |
|
|
|
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(bmi(val, val1)); |
|
|
|
jLabel.setText(String.valueOf(res)); |
|
|
|
} |
|
|
|
button.addActionListener(e -> { |
|
|
|
String text = jTextField.getText(); |
|
|
|
String text1 = textField.getText(); |
|
|
|
double val = Double.parseDouble(text); |
|
|
|
double val1 = Double.parseDouble(text1); |
|
|
|
double res = bmi(val, val1); |
|
|
|
jLabel.setText(String.valueOf(res)); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
public double bmi(double height, double weight) { |
|
|
|
double result = 0.0; |
|
|
|
result = weight / (height * height); |
|
|
|
double roundOff = Math.round(result * 100.0) / 100.0; |
|
|
|
return roundOff; |
|
|
|
return Math.round(result * 100.0) / 100.0; |
|
|
|
} |
|
|
|
|
|
|
|
public double steuer19(double x) |
|
|
@ -414,7 +443,7 @@ public class TasksFrame extends JFrame { |
|
|
|
@Override |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
String textPreis = preis.getText(); |
|
|
|
double val_preis = Double.valueOf(textPreis); |
|
|
|
double val_preis = Double.parseDouble(textPreis); |
|
|
|
double res = steuer7(val_preis); |
|
|
|
ausgabe.setText("Die Steuer beträgt:" +res +"€"); |
|
|
|
|
|
|
@ -455,14 +484,11 @@ public class TasksFrame extends JFrame { |
|
|
|
jPanel.add(jTextField); |
|
|
|
jPanel.add(jLabel); |
|
|
|
|
|
|
|
button.addActionListener(new ActionListener() { |
|
|
|
@Override |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
String text = jTextField.getText(); |
|
|
|
Integer val = Integer.valueOf(text); |
|
|
|
int res = Integer.valueOf(umrechnen(val)); |
|
|
|
jLabel.setText(String.valueOf(res)); |
|
|
|
} |
|
|
|
button.addActionListener(e -> { |
|
|
|
String text = jTextField.getText(); |
|
|
|
int val = Integer.parseInt(text); |
|
|
|
int res = Integer.parseInt(umrechnen(val)); |
|
|
|
jLabel.setText(String.valueOf(res)); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
@ -513,18 +539,15 @@ public class TasksFrame extends JFrame { |
|
|
|
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(); |
|
|
|
Integer val_a = Integer.valueOf(texta); |
|
|
|
Integer val_b = Integer.valueOf(textb); |
|
|
|
Integer val_c = Integer.valueOf(textc); |
|
|
|
int res = roundSum(val_a, val_b, val_c); |
|
|
|
jLabel.setText(String.valueOf(res)); |
|
|
|
} |
|
|
|
button.addActionListener(e -> { |
|
|
|
String texta = a.getText(); |
|
|
|
String textb = b.getText(); |
|
|
|
String textc = c.getText(); |
|
|
|
int val_a = Integer.parseInt(texta); |
|
|
|
int val_b = Integer.parseInt(textb); |
|
|
|
int val_c = Integer.parseInt(textc); |
|
|
|
int res = roundSum(val_a, val_b, val_c); |
|
|
|
jLabel.setText(String.valueOf(res)); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
@ -570,18 +593,13 @@ public class TasksFrame extends JFrame { |
|
|
|
jPanel.add(b); |
|
|
|
jPanel.add(jLabel); |
|
|
|
|
|
|
|
button.addActionListener(new ActionListener() { |
|
|
|
@Override |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
String texta = a.getText(); |
|
|
|
String textb = b.getText(); |
|
|
|
Integer val_a = Integer.valueOf(texta); |
|
|
|
Integer val_b = Integer.valueOf(textb); |
|
|
|
int res = kgV(val_a, val_b); |
|
|
|
jLabel.setText(String.valueOf(res)); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
button.addActionListener(e -> { |
|
|
|
String texta = a.getText(); |
|
|
|
String textb = b.getText(); |
|
|
|
int val_a = Integer.parseInt(texta); |
|
|
|
int val_b = Integer.parseInt(textb); |
|
|
|
int res = kgV(val_a, val_b); |
|
|
|
jLabel.setText(String.valueOf(res)); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
@ -614,12 +632,9 @@ public class TasksFrame extends JFrame { |
|
|
|
jPanel.add(jTextField); |
|
|
|
jPanel.add(jLabel); |
|
|
|
|
|
|
|
button.addActionListener(new ActionListener() { |
|
|
|
@Override |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
int r = quer(Integer.valueOf(jTextField.getText())); |
|
|
|
jLabel.setText(String.valueOf(r)); |
|
|
|
} |
|
|
|
button.addActionListener(e -> { |
|
|
|
int r = quer(Integer.valueOf(jTextField.getText())); |
|
|
|
jLabel.setText(String.valueOf(r)); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
@ -663,12 +678,9 @@ public class TasksFrame extends JFrame { |
|
|
|
jPanel.add(jTextField); |
|
|
|
jPanel.add(jLabel); |
|
|
|
|
|
|
|
button.addActionListener(new ActionListener() { |
|
|
|
@Override |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
int r = ePhi(Integer.valueOf(jTextField.getText())); |
|
|
|
jLabel.setText(String.valueOf(r)); |
|
|
|
} |
|
|
|
button.addActionListener(e -> { |
|
|
|
int r = ePhi(Integer.valueOf(jTextField.getText())); |
|
|
|
jLabel.setText(String.valueOf(r)); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
@ -714,6 +726,7 @@ public class TasksFrame extends JFrame { |
|
|
|
button.setBounds(10, 50, 150, 30); |
|
|
|
button.setVisible(true); |
|
|
|
button.setBackground(Color.BLUE); |
|
|
|
button.setFont(new java.awt.Font("Arial", Font.BOLD, 12)); |
|
|
|
button.addActionListener(new ActionListener() { |
|
|
|
@Override |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|