Assignment #58
Code
///jack newsom
///period 5
///program name OneShot
///filename OneShot.java
///date completed 10/6/15
import java.util.Scanner;
import java.util.Random;
public class OneShot
{
public static void main( String[] args )
{
Random r = new Random();
Scanner shotbot = new Scanner(System.in);
System.out.println("I'm thinking of a number between 1-100. Try to guess it!");
int guess = shotbot.nextInt();
int ans = 1 + r.nextInt(99);
if ( guess > ans )
System.out.println("Sorry, you are too high. I was thinking of " + ans + ".");
else if ( guess < ans )
System.out.println("Sorry, you are too low. I was thinking of " + ans + ".");
else
System.out.println("You guessed it! What are the odds?!?");
}
}
Picture of the output