Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Random;
- import java.util.Scanner;
- public class SecretNumber
- {
- public static void main(String[] args)
- {
- Scanner Scan = new Scanner(System.in);
- System.out.println("Enter a number");
- int a = Scan.nextInt();
- System.out.println("Enter another number");
- int b = Scan.nextInt();
- System.out.println("Enter another number");
- int c = Scan.nextInt();
- if (a < b && a < c)
- {
- System.out.println("the first number is smallest " + a);
- }
- else if (b < a && b < c)
- {
- System.out.println("the second number is smallest " + b);
- } else
- {
- System.out.println("the third number is smallest " + c);
- }
- Random intNum = new Random();
- int actual = intNum.nextInt(11);
- System.out.println("Please guess a number between 1 and 10");
- int z = Scan.nextInt();
- if (z >10)
- {
- System.out.println("The number needs to be between 1 and 10");
- System.out.println("guess again");
- int y = Scan.nextInt();
- if (y==actual)
- {
- System.out.println("you got it!");
- }
- if (y != actual)
- {
- int x = y-actual;
- System.out.println("Nice try, you missed it by " + x);
- }
- }
- else if (z == actual)
- {
- System.out.println("you guessed it!");
- }
- else if (z != actual)
- {
- System.out.println("guess again");
- int y = Scan.nextInt();
- if (y==actual)
- {
- System.out.println("you got it!");
- }
- if (y != actual)
- {
- int x = y-actual;
- System.out.println("Nice try, you missed it by " + x);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement