Assignemnt #58

Code

    ///Name: Joshua Bautista
    ///Period: 6
    ///Project Name: One Shot Hi-lo
    ///File Name: Hilo.java
    ///Date: 1/7/2016
    
    import java.util.Scanner;
import java.util.Random;

public class OneShot
{
    public static void main( String[] args )
    {
    Random r = new Random();
    Scanner keyboard = new Scanner(System.in);
    
    int guess, x;
    x = 1 + r.nextInt(100);
        
    
    System.out.println(" I'm thinkinhg of a number between 1-100. Try to guess it.");
    System.out.print(">");
    guess = keyboard.nextInt();
    
    if ( guess == x )
    {
        System.out.println(" You guessed it! What are the odds?!? ");
    }
    
    else if ( guess > x )
    {
        System.out.println(" Sorry, your number was too high. I was thinking of " + x + ".");
    }

    else if ( guess < x )
    {
        System.out.println(" Sorry, your number was too low. I was thinking of " + x + ".");
    }

}
}
    

Picture of the output

Assignment 1