Advertisement
Guest User

Untitled

a guest
Sep 2nd, 2014
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. import javax.swing.JOptionPane;
  2.  
  3. public class Tools {
  4.  
  5. static int ZahlAbfragen(){
  6. String s = JOptionPane.showInputDialog("Bitte gib eine Zahl ein.");
  7. int zahl = Integer.parseInt(s);
  8. return zahl;
  9. }
  10.  
  11. static void TextAusgeben(String text){
  12. System.out.println(text);
  13. }
  14.  
  15. static int StringZuZahl(String s){
  16. int zahl = Integer.parseInt( s);
  17. return zahl;
  18. }
  19.  
  20. static double KommazahlAbfrage(){
  21. String s = JOptionPane.showInputDialog("Bitte gib eine Kommazahl ein.");
  22.  
  23. try {
  24. double zahl = Double.parseDouble(s);
  25. return zahl;
  26. } catch (Exception e) {
  27. TextAusgeben("Gib eine Zahl ein!");
  28. return KommazahlAbfrage();
  29. }
  30.  
  31. }
  32.  
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement