Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.lang.Math;
- import java.util.Random;
- /**
- * Write a description of class Final here.
- *
- * Sudo
- * 5/11/11
- */
- public class Final{//starts class definiton
- public static void main(String[] args) {
- int high;
- int high2;
- int low;
- int low2;
- int half;
- int points = 1000;
- int pointsRisk;
- int pointsWin;
- int pointsWin2;
- int pointsLose;
- int pointsLose2;
- int predict;
- int rdmNum;
- int rdmNum2;
- Scanner input = new Scanner(System.in); // Input Scanner
- System.out.println("The Seth's High Low Game");
- System.out.println("Low Number");
- low = input.nextInt();
- System.out.println("High Number");
- high = input.nextInt();
- low2 = high/2 - 1;
- half = high/2;
- high2 = half + 1;
- System.out.println("Rules");
- System.out.println("Numbers starting at " + low + " through " + low2 + " are low");
- System.out.println("Numbers starting at " + high2 + " through " + high + " are high");
- System.out.println("Number " + half + " is neither high or low");
- System.out.println("Your start with " + points + " points");
- do {
- System.out.print("Enter points you wish to risk at your own cost: ");
- pointsRisk = input.nextInt();
- System.out.print("Predict (1=High, 0=Low): ");
- predict = input.nextInt();
- //create random number
- Random generator = new Random();
- rdmNum = generator.nextInt(high - low) + 1;
- rdmNum2 = high - rdmNum;
- if (predict == 1 && rdmNum2 > high2){
- System.out.println("The random number is " + rdmNum2);
- System.out.println("You Win!");
- points = points + pointsRisk;
- System.out.println("You have " + points + " points");
- }else if(predict == 0 && rdmNum2 < low2){
- System.out.println("The random number is " + rdmNum2);
- System.out.println("You Win!");
- points = points + pointsRisk;
- System.out.println("You have " + points + " points");
- }else if(predict == 1 && rdmNum2 < low2){
- System.out.println("The random number is " + rdmNum2);
- System.out.println("You Lose!");
- points = points - pointsRisk;
- System.out.println("You have " + points + " points");
- }else if(predict == 0 && rdmNum2 > low2){
- System.out.println("The random number is " + rdmNum2);
- System.out.println("You Lose!");
- points = points - pointsRisk;
- System.out.println("You have " + points + " points");
- }
- }while (points == 0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement