If statement part 2 #51 (I dislike being Near last)
Code
/// Name: Amir Salehi
/// Period: 7
/// Program Name:Number Guessing game
/// File Name: NumberGuessinggame.java
/// Date Finished: 11/16/2015
import java.util.Scanner;
public class GuessingGame {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int correct = 6, guess;
System.out.print("I'm thinking of a number from 0 - 10. What is it? ");
guess = input.nextInt();
if (guess == correct) {
System.out.println("Correct! The answer was " + correct + "!");
} else {
System.out.println("Wrong! The correct answer was " + correct + "!");
}
}
}
Picture of the output