Programming Assignment #55
Code
/// Name: Dylan Sleeper
/// Period: 6
/// Program Name: Random
/// File Name: random.java
/// Date Finished: 10/22/2015
import java.util.Scanner;
import java.util.Random;
public class random{
public static void main(String[] args){
Scanner k = new Scanner(System.in);
Random r = new Random();
int num = r.nextInt(10) + 1;
System.out.println("I'm thinking of a number 1 - 10");
System.out.print("Your guess: ");
int guess = k.nextInt();
System.out.println("");
if(num == guess){
System.out.println("That's right! My number was " + num);
}
else{
System.out.println("Nope that's not it. My number was " + num);
}
}
}
Outputs