OneShotLimit

Code

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

public class OneShotLimit
{
	public static void main ( String[] args )
	{
        Scanner keyboard = new Scanner(System.in);
		Random r = new Random();
        
        int num, tries;
        
        tries = 0;

		int choice = 1 + r.nextInt(100);
		String response = "";
        
        System.out.println(" I'm thinking of a number from 1-100 can you guess it ");
        num = keyboard.nextInt();
        tries++;
        
        if ( choice == num )
        {
            System.out.println(" Wow you got it...too easy ");
        }
        while ( choice > num && tries < 8 )
        {
            System.out.println(" To low "  );
            System.out.println(" Nope guess # " + tries );
            num = keyboard.nextInt();
            tries++;
        }
        while ( choice < num && tries < 8 )
        {
            System.out.println(" To high.  ");
            System.out.println(" Nope guess # " + tries );
            num = keyboard.nextInt();
            tries++;
        }
        if ( tries >= 8 )
        {
            System.out.println( " NOOOOPE you had your chance " );
        }
    }
}

OneShotLimit

Assignment 66