Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.32 KB | None | 0 0
  1. else if (a == 6){
  2.             boolean InGame = true;
  3.             while (InGame == true);
  4.  
  5.             System.out.println("Glückspiel: Wer näher an der zufälligen Zahl ist gewinnt! 1-100");
  6.             System.out.println("Spieler Eins");
  7.             double playerOne = scan.nextDouble();
  8.             System.out.println("Spieler Zwei");
  9.             double playerTwo = scan.nextDouble();
  10.  
  11.             double randomValue = Math.random() * 100.0;
  12.  
  13.             // Math.abs() ist eine Methode die den Betrag einer Zahl zurueck gibt.
  14.             double spacingOne = Math.abs(playerOne - randomValue);
  15.             double spacingTwo = Math.abs(playerTwo - randomValue);
  16.             System.out.println("Die Random Zahl war " + randomValue);
  17.  
  18.             if (spacingOne < spacingTwo) {
  19.                 System.out.println("Spieler Eins hat gewonnen!");
  20.             }
  21.  
  22.             if (spacingOne > spacingTwo) {
  23.                 System.out.println("Spieler Zwei hat gewonnen!");
  24.             }
  25.  
  26.             if (spacingOne == spacingTwo) {
  27.                 System.out.println("Unentschieden!");
  28.             }
  29.             System.out.println("Wenn du nochmal spielen willst schreibe 'ja' wenn nicht 'nein'");
  30.             String PlayAgain = scan.nextLine();
  31.             if  (PlayAgain == "Ja");
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.         }//SpielSpiel Ende
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement