Assignemnt #58

Code

///colin hinton
///5th period
///Hi Lo
///HiLo.java
///10/30/2015

import java.util.Scanner;
import java.util.Random;

class HiLo
{
    public static void main (String [] args)
    {
        Scanner keyboard = new Scanner(System.in);
        
        int guess;
        
        System.out.println("Im thinking of a number between 1-100, guess it");
        guess = keyboard.nextInt();
        
        Random r = new Random();
        
        int x = (1 + r.nextInt(100));
        if ( guess == x)
        {
            System.out.println(" You guessed it right, wow, congrats.");
        }
        else if ( guess < x)
        {
            System.out.println(" You were too low, too bad  the asnwer was actully " + x);
        }
        else if ( guess > x)
        {
            System.out.println("You were too high, the random number was " + x);
        }
        else 
        {
            System.out.print("You goofed");
        }
    }
}
  

Picture of the output

Assignment 1