Browse Source

Quersumme added

remotes/origin/develop
fdai6040 2 years ago
parent
commit
4cadc56405
  1. 47
      src/main/java/src/TasksFrame.java

47
src/main/java/src/TasksFrame.java

@ -75,19 +75,60 @@ public class TasksFrame extends JFrame {
setupEulerschePhiFunk();
setupQuersumme();
}
private void setupQuersumme() {
JPanel jPanel = setupPanel("Quersumme");
JButton button = new JButton("Quersumme");
button.setVisible(true);
button.setBounds(10, 65, 100, 30);
JTextField jTextField = new JTextField();
jTextField.setVisible(true);
jTextField.setBounds(10, 40, 30, 20);
JLabel jLabel = new JLabel();
jLabel.setVisible(true);
jLabel.setBounds(10,90,60,30);
jPanel.add(button);
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));
}
});
}
public int quer(Integer n) {
int quersumme = 0;
for (int x = n; x > 0; x = x / 10) {
quersumme = quersumme + x % 10;
}
return quersumme;
}
private void setupEulerschePhiFunk() {
JPanel jPanel = setupPanel("Eulersche Phi Funktion");
Button button = new Button("Calc Phi");
JButton button = new JButton("calc Phi");
button.setVisible(true);
button.setBounds(120, 50, 100, 30);
button.setBounds(10, 65, 100, 30);
JTextField jTextField = new JTextField();
jTextField.setVisible(true);
jTextField.setBounds( 10, 40, 60, 20);
jTextField.setBounds( 10, 40, 30, 20);
JLabel jLabel = new JLabel();
jLabel.setVisible(true);

Loading…
Cancel
Save