Assignemnt #58 and One Shot Hi-Lo
Code
/// Name: Brian Phillips
/// Period: 5
/// Program name: One Shot Hi-Lo
/// File Name: NumberGuessing3.java
/// Date Finished: 12/3/2015
import java.util.Scanner;
import java.util.Random;
public class NumberGuessing3
{
public static void main(String[] args)
{
Scanner keyboard = new Scanner(System.in);
Random r = new Random();
int choice = 1 + r.nextInt(100);
int hisNumber;
System.out.println("Number Guessing Game");
System.out.println();
System.out.println("Try to Guess my number between 1 and 100. ");
hisNumber = keyboard.nextInt();
System.out.println();
if ( choice == hisNumber )
{
System.out.println( "Wow" + choice + " was my number." );
}
if ( choice > hisNumber )
{
System.out.println( "Sorry too low my number was " + choice + ".");
}
if ( choice < hisNumber )
{
System.out.println( "Sorry too high my number was " + choice + ".");
}
}
}
Picture of the output