1
0

Add chapters 9-17 for the java book

This commit is contained in:
2025-12-01 14:14:57 +01:00
parent a680b83e47
commit 2da137aea8
54 changed files with 3063 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
import javax.swing.JOptionPane;
public class Task1 {
public static void main(String[] arguments) {
var result = JOptionPane.showConfirmDialog(null,
"Bestätigen Sie die Eingabe", "Bestätigung", JOptionPane.YES_NO_CANCEL_OPTION);
switch (result) {
case JOptionPane.YES_OPTION:
JOptionPane.showMessageDialog(null, "Ja");
break;
case JOptionPane.NO_OPTION:
JOptionPane.showMessageDialog(null, "Nein");
break;
case JOptionPane.CANCEL_OPTION:
JOptionPane.showMessageDialog(null, "Abbrechen");
break;
}
}
}

View File

@@ -0,0 +1,11 @@
import javax.swing.JOptionPane;
public class Task2 {
public static void main(String[] arguments) {
var rawResult = JOptionPane.showInputDialog(null, "Geben Sie eine Zahl ein:");
var input = Integer.parseInt(rawResult);
Double result = Math.sqrt(input);
JOptionPane.showMessageDialog(null, result.toString(), "Die Wurzel ist:", JOptionPane.INFORMATION_MESSAGE);
}
}