SHARE
TWEET

Untitled

a guest Aug 12th, 2017 43 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2.  
  3.  
  4. public class GussingGame {
  5.     public static void main(String[] args) {
  6.         int score = 0;
  7.         int count = 0;
  8.         int game = 0;
  9.         int win = 0;
  10.         int lose = 0;
  11.         int selection = -1;
  12.  
  13.         Scanner input = new Scanner(System.in);
  14.         System.out.println("Your score is " + win + " wins and " + lose + " losses");
  15.         System.out.println("How many games do you want to play?");
  16.             selection = input.nextInt();
  17.             while (game != selection){
  18.             while (count < 8){
  19.             int number = (int)(Math.random() * 101);
  20.             System.out.println("Guess a number between 0 and 100");
  21.             int guess = 0;
  22.  
  23.  
  24.             while (guess != number){
  25.                 System.out.print("\nEnter your guess: ");
  26.                 guess = input.nextInt();
  27.  
  28.                 if (guess == number){
  29.                     System.out.println("Yes, the number is " + number);
  30.                     win++;
  31.                     game++;
  32.                 }
  33.                 else if (guess > number){
  34.                     System.out.println("Your guess is too high");
  35.                     count++;
  36.                 }
  37.                 else if (guess < number){
  38.                     System.out.println("Your guess is too low");
  39.                     count++;
  40.                 }
  41.                 if (count > 8){
  42.                 System.out.println("You lose");
  43.                 lose++;
  44.                 break;
  45.  
  46.             }
  47.             }
  48.  
  49.  
  50.     }
  51.  
  52.     System.out.println("Your score is " + win + " wins and " + lose + " losses");
  53.     if (game == selection){
  54.         break;
  55.     }
  56.  
  57.         }
  58.     }
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.     }
RAW Paste Data
Top