Assignemnt #58
Code
/// Name: Daniel Nguyen
/// Period: 6
/// Program Name: OneShot Program
/// File Name: OneShot.java
/// Date Finished: 9/9/2015
import java.util.Random;
import java.util.Scanner;
public class OneShot
{
public static void main ( String[] args )
{
Scanner keyboard = new Scanner(System.in);
Random r = new Random();
int rng = 1 + r.nextInt(100);
int guess;
System.out.println("HERE COMES THE DICE!!!");
System.out.println("I'm gunna think of a number from 1-100.");
System.out.println("Hmmmm.... OK!! I got it");
System.out.println("Try to guess!");
guess = keyboard.nextInt();
if (guess == rng) {
System.out.println("Good job! You got it!");
}
else if (guess < rng) {
System.out.println("Your guess is lower than my number sorry :/");
}
else if (guess > rng) {
System.out.println("Your guess is higher than my number sorry :/");
}
}
}
Picture of the output