Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * In-Class_Project.java 10/01/12
- *
- * @author - Edward Rollf
- * @author -
- * @author - Id nnnnnnn
- *
- * @author - I received help from ...
- *
- */
- import java.util.Scanner;
- import java.util.Random;
- public class InClass_Project
- {
- public static void main(String[] args)
- {
- Scanner scan = new Scanner (System.in);
- Random ran = new Random ();
- System.out.println("Welcome! You are playing Guess the number!");
- System.out.println("Please guess the number or if you want to quit then type -1: ");
- int guess=scan.nextInt();
- int gen=ran.nextInt(100);
- int count=1;
- while (guess!=-1 && guess!=gen && count!=9)
- {
- if(guess>gen)
- {
- System.out.println("You are two high.");
- System.out.println("Guess again or -1 to quit");
- guess=scan.nextInt();
- }
- else if(guess<gen)
- {
- System.out.println("You are to low.");
- System.out.println("Guess again or -1 to quit.");
- guess=scan.nextInt();
- }
- else if(guess==gen)
- {
- System.out.println("Correct");
- System.out.println("Start a new game or -1 to quit.");
- guess=scan.nextInt();
- }
- count++;
- if(count=10);
- System.out.println("You Suck! Try again!!!");
- }
- }
- }
Add Comment
Please, Sign In to add comment