Guest User

Untitled

a guest
Dec 10th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. /**
  2. * In-Class_Project.java 10/01/12
  3. *
  4. * @author - Edward Rollf
  5. * @author -
  6. * @author - Id nnnnnnn
  7. *
  8. * @author - I received help from ...
  9. *
  10. */
  11.  
  12.  
  13. import java.util.Scanner;
  14. import java.util.Random;
  15.  
  16. public class InClass_Project
  17. {
  18. public static void main(String[] args)
  19. {
  20. Scanner scan = new Scanner (System.in);
  21. Random ran = new Random ();
  22. System.out.println("Welcome! You are playing Guess the number!");
  23. System.out.println("Please guess the number or if you want to quit then type -1: ");
  24. int guess=scan.nextInt();
  25. int gen=ran.nextInt(100);
  26. int count=1;
  27.  
  28. while (guess!=-1 && guess!=gen && count!=9)
  29. {
  30.  
  31. if(guess>gen)
  32. {
  33. System.out.println("You are two high.");
  34. System.out.println("Guess again or -1 to quit");
  35. guess=scan.nextInt();
  36. }
  37. else if(guess<gen)
  38. {
  39. System.out.println("You are to low.");
  40. System.out.println("Guess again or -1 to quit.");
  41. guess=scan.nextInt();
  42. }
  43. else if(guess==gen)
  44. {
  45. System.out.println("Correct");
  46. System.out.println("Start a new game or -1 to quit.");
  47. guess=scan.nextInt();
  48. }
  49. count++;
  50. if(count=10);
  51. System.out.println("You Suck! Try again!!!");
  52. }
  53.  
  54. }
  55. }
Add Comment
Please, Sign In to add comment