12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- import java.util.Scanner;
- import java.util.ArrayList;
-
- public class Main
- {
- public static void Main()
- {
-
- }
-
- public static void TooLargeTooSmall()
- {
- Double random = Math.random() * 100.0;
- int number1 = random.intValue();
- int guesses = 0;
- ArrayList<Integer> alreadyGuessed = new ArrayList<Integer>();
- boolean win = false;
-
- random = Math.random() * 100.0;
- int number2 = random.intValue();
- int min = Math.min(number1, number2);
- int max = Math.max(number1, number2);
-
- Double randomAnswer = (Math.random() * ((max - min) + 1)) + min;
- int answer = randomAnswer.intValue();
-
- System.out.println("Please choose a number between: " + min + " and " + max + ".");
- Scanner scanner = new Scanner(System.in);
-
- while(win == false)
- {
- int guess = scanner.nextInt();
-
- if(alreadyGuessed.indexOf(guess) == -1)
- {
- alreadyGuessed.add(guess);
- }
-
- if(guess == answer){
- System.out.println("You win!");
- System.out.println("You guessed: " + alreadyGuessed.size());
- win = true;
- } else if(guess > answer)
- {
- System.out.println("Too high, guess again:");
- } else{
- System.out.println("Too low, guess again:");
- }
- }
-
-
-
- }
- }
|