Assignemnt #55 and Number Guessing Game
Code
/// Name: Kyle Ivy
/// Period: 5
/// Program Name: NumberGuess
/// File Name: NumberGuess.java
/// Date Finished: 12/2/2015
import java.util.Random;
import java.util.Scanner;
public class NumberGuess {
public static void main( String[] args ) {
Random r = new Random();
Scanner keyboard = new Scanner(System.in);
int secretNumber = 1 + r.nextInt(10);
int guess;
System.out.println("I'm thinking of a number between 1-10 ");
System.out.println();
System.out.print("Yout Guess: ");
guess = keyboard.nextInt();
if (guess == secretNumber )
System.out.println("That's correct! My secret number was " + secretNumber );
else System.out.println( "That is incorrect, I was thinking of " + secretNumber );
}
}
prog55.PNG