Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. import java.util.Random;
  2. import java.util.Scanner;
  3.  
  4.  
  5. public class SecretNumber
  6. {
  7. public static void main(String[] args)
  8. {
  9.  
  10. Scanner Scan = new Scanner(System.in);
  11. System.out.println("Enter a number");
  12. int a = Scan.nextInt();
  13. System.out.println("Enter another number");
  14. int b = Scan.nextInt();
  15. System.out.println("Enter another number");
  16. int c = Scan.nextInt();
  17.  
  18. if (a < b && a < c)
  19. {
  20. System.out.println("the first number is smallest " + a);
  21. }
  22. else if (b < a && b < c)
  23. {
  24. System.out.println("the second number is smallest " + b);
  25. } else
  26. {
  27. System.out.println("the third number is smallest " + c);
  28. }
  29.  
  30.  
  31. Random intNum = new Random();
  32. int actual = intNum.nextInt(11);
  33.  
  34. System.out.println("Please guess a number between 1 and 10");
  35. int z = Scan.nextInt();
  36.  
  37. if (z >10)
  38. {
  39. System.out.println("The number needs to be between 1 and 10");
  40. System.out.println("guess again");
  41. int y = Scan.nextInt();
  42.  
  43. if (y==actual)
  44. {
  45. System.out.println("you got it!");
  46. }
  47. if (y != actual)
  48. {
  49. int x = y-actual;
  50. System.out.println("Nice try, you missed it by " + x);
  51.  
  52. }
  53. }
  54. else if (z == actual)
  55. {
  56. System.out.println("you guessed it!");
  57. }
  58. else if (z != actual)
  59. {
  60. System.out.println("guess again");
  61. int y = Scan.nextInt();
  62.  
  63. if (y==actual)
  64. {
  65. System.out.println("you got it!");
  66. }
  67. if (y != actual)
  68. {
  69. int x = y-actual;
  70. System.out.println("Nice try, you missed it by " + x);
  71.  
  72. }
  73. }
  74.  
  75.  
  76.  
  77. }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement