Assignment 58: One Shot High-Low
Code
/// Name: Ryan McAteer
/// Period: 5
/// Program Name: One Shot High Low
/// File Name: Assignment58.java
/// Date Finished: 11/16/15
import java.util.Random;
import java.util.Scanner;
public class Assignment58
{
public static void main ( String[] args )
{
int guess;
Random r = new Random();
Scanner keyboard = new Scanner(System.in);
int theNumber = 1 + r.nextInt(100);
System.out.println("I'm thinking of a number between 1-100. Try to guess it.");
System.out.print("> ");
guess = keyboard.nextInt();
if ( guess == theNumber )
System.out.println("MASTER GUESSER! WHAT ARE THE ODDS!");
else if ( guess > theNumber )
System.out.println("Too high. I was thinking of " + theNumber + ".");
else if ( guess < theNumber )
System.out.println("Too low. I was thinking of " + theNumber + ".");
else
System.out.println("MATH ERROR");
}
}
Picture of the output