Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class RandGuess
- {
- public static void main(String[] args)
- {
- Scanner guess = new Scanner(System.in);
- System.out.print("Make A Guess: ");
- int user = guess.nextInt();
- Random rand = new Random();
- int x = rand.nextInt( 100 ) + 1;
- int y = rand.nextInt( 100 ) + 1;
- while (user > 100 || user < 1)
- {
- System.out.print("Enter a Number Between 1 and 10");
- }
- if (user < 100 && user > 1)
- {
- if (x < y && Math.abs(x-y) < 5)
- {
- int z = rand.nextInt( y - x ) + x;
- if (user == z)
- {
- System.out.print("That's Right! You're Cool!");
- }
- if (user != z && (user - z < 3 || z - user < 3))
- {
- System.out.print(z);
- }
- while (user != z && (user - z > 3 || z - user > 3))
- {
- System.out.print("You Missed By a Mile!");
- }
- }
- if (y < x && Math.abs(x-y) < 5)
- {
- int z = rand.nextInt( x - y ) + y;
- if (user == z)
- {
- System.out.print("That's Right! You're Cool!");
- }
- if (user != z && (user - z < 3 || z - user < 3))
- {
- System.out.print(z);
- }
- while (user != z && (user - z > 3 || z - user > 3))
- {
- System.out.print("You Missed By a Mile!");
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment