Add chapters 9-17 for the java book
This commit is contained in:
20
Java-Kompendium/kap11/Task1.java
Normal file
20
Java-Kompendium/kap11/Task1.java
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Java-Kompendium/kap11/Task2.java
Normal file
11
Java-Kompendium/kap11/Task2.java
Normal 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user