Programming Assignment #52
Code
/// Name: Dylan Sleeper
/// Period: 6
/// Program Name: NumberGame
/// File Name: NumberGame.java
/// Date Finished: 10/22/2015
import java.util.Scanner;
public class NumberGame{
public static void main(String[] args){
int num = 2;
Scanner keyboard = new Scanner(System.in);
System.out.println("Here's a fun guessing game!");
System.out.println("");
System.out.print("I'm thinking of a number 1-10 Try and guess it! ");
int guess = keyboard.nextInt();
System.out.println("");
if(num == guess){
System.out.println("You got it! My number was " + num);
}
else{
System.out.println("Nope, not quite! My number was " + num);
}
}
}
Outputs