Advertisement
Guest User

Untitled

a guest
Aug 18th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. import java.util.Scanner;
  2. import java.lang.Math;
  3. import java.util.Random;
  4. /**
  5. * Write a description of class Final here.
  6. *
  7. * Sudo
  8. * 5/11/11
  9. */
  10. public class Final{//starts class definiton
  11. public static void main(String[] args) {
  12. int high;
  13. int high2;
  14. int low;
  15. int low2;
  16. int half;
  17. int points = 1000;
  18. int pointsRisk;
  19. int pointsWin;
  20. int pointsWin2;
  21. int pointsLose;
  22. int pointsLose2;
  23. int predict;
  24. int rdmNum;
  25. int rdmNum2;
  26. Scanner input = new Scanner(System.in); // Input Scanner
  27. System.out.println("The Seth's High Low Game");
  28. System.out.println("Low Number");
  29. low = input.nextInt();
  30. System.out.println("High Number");
  31. high = input.nextInt();
  32. low2 = high/2 - 1;
  33. half = high/2;
  34. high2 = half + 1;
  35.  
  36. System.out.println("Rules");
  37. System.out.println("Numbers starting at " + low + " through " + low2 + " are low");
  38. System.out.println("Numbers starting at " + high2 + " through " + high + " are high");
  39. System.out.println("Number " + half + " is neither high or low");
  40. System.out.println("Your start with " + points + " points");
  41.  
  42. do {
  43. System.out.print("Enter points you wish to risk at your own cost: ");
  44. pointsRisk = input.nextInt();
  45. System.out.print("Predict (1=High, 0=Low): ");
  46. predict = input.nextInt();
  47. //create random number
  48. Random generator = new Random();
  49. rdmNum = generator.nextInt(high - low) + 1;
  50. rdmNum2 = high - rdmNum;
  51.  
  52. if (predict == 1 && rdmNum2 > high2){
  53. System.out.println("The random number is " + rdmNum2);
  54. System.out.println("You Win!");
  55. points = points + pointsRisk;
  56. System.out.println("You have " + points + " points");
  57. }else if(predict == 0 && rdmNum2 < low2){
  58. System.out.println("The random number is " + rdmNum2);
  59. System.out.println("You Win!");
  60. points = points + pointsRisk;
  61. System.out.println("You have " + points + " points");
  62. }else if(predict == 1 && rdmNum2 < low2){
  63. System.out.println("The random number is " + rdmNum2);
  64. System.out.println("You Lose!");
  65. points = points - pointsRisk;
  66. System.out.println("You have " + points + " points");
  67. }else if(predict == 0 && rdmNum2 > low2){
  68. System.out.println("The random number is " + rdmNum2);
  69. System.out.println("You Lose!");
  70. points = points - pointsRisk;
  71. System.out.println("You have " + points + " points");
  72. }
  73. }while (points == 0);
  74. }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement