Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner; //imports a thing
- public class LessonFive {
- public static void main(String []args) {
- int Num;
- Num = (int) (Math.random() * 999 + 1);
- //the above make Num somewhere between 1 and 1000
- Scanner keyboard = new Scanner(System.in);
- int guess = -1;
- while (guess != Num) {
- System.out.print("Enter a guess: ");
- guess = keyboard.nextInt();
- //allows the user to guess a number
- System.out.println(guess);
- if(guess == Num) {
- System.out.println("You're rignt!!");
- }
- if(guess < Num) {
- System.out.println("Too low!");
- }
- if(guess > Num) {
- System.out.println("Too high!");
- //tells user if too high, too low, or correct
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement