- import java.util.Scanner;
- import java.util.Random;
- public class HiLo
- {
- public static void main(String[] args)
- {
- Random generator = new Random();
- Scanner myscanner = new Scanner(System.in);
- int guess;
- System.out.println("Hello!");
- //System.out.println("Your randomly generated number is: "); for debugging purposes
- int rnum = generator.nextInt(100) + 1;
- //System.out.println(rnum); for debugging purposes
- int count = 1;
- int exitwhile = 0;
- System.out.println("Can you guess the number from 1 to 100?");
- while (exitwhile == 0)
- {
- System.out.println("Enter a number!");
- guess = myscanner.nextInt();
- count = count + 1;
- if (guess < rnum)
- {
- System.out.println("That number was too low, try again!");
- }
- else if (guess > rnum)
- {
- System.out.println("That number was too high, try again!");
- }
- else
- { // guessed right
- System.out.println("Wow it took you " + count + " tries...");
- if ( count == 1)
- {
- System.out.println("You must be cheating!");
- }
- else if (count < 5)
- {
- System.out.println("You are very clever!");
- }
- else if (count <7)
- {
- System.out.println("Not a bad job, not a good one either..");
- }
- else if (count < 10)
- {
- System.out.println("Are you even trying?");
- }
- else
- {
- System.out.println("Never bother me again! Be Gone!" );
- }
- exitwhile = 1;
- } // end else
- }//endwhile
- System.out.println(" ");
- System.out.println(" ");
- System.out.println(" ");
- System.out.println(" ******************************");
- System.out.println(" * ***** ***** ***** ***** *");
- System.out.println(" * * * * * * * * *");
- System.out.println(" * * ** ***** * * * *** *");
- System.out.println(" * * * * * * * * *");
- System.out.println(" * ***** * * * * ***** *");
- System.out.println(" * *");
- System.out.println(" * ***** * * ***** **** *");
- System.out.println(" * * * * * * * * *");
- System.out.println(" * * * * * *** **** *");
- System.out.println(" * * * * * * * * *");
- System.out.println(" * ***** * ***** * * *");
- System.out.println(" ******************************");
- System.out.println(" ");
- System.out.println(" ");
- }//end game main
- }//end game
java
By: hilo game | Date: Jan 25 2008 03:35 | Format: None | Expires: never | Size: 2.69 KB | Hits: 1248
Latest pastes
1 days ago
1 days ago
2 days ago
4 days ago
5 days ago