115k views
1 vote
Write a user input program using if else statements ONLY name of program "Magic number" the user will try guess the Magic number. The user will enters the number to guess and computer will tell the user if the number matches the Magic number and then determine if the number is smaller or greater than the initial number. The Number that is guessed must be of type int and use Math.random() function to give it random value in range 1 thru 100.

1 Answer

4 votes

Answer:

Step-by-step explanation:

Hint**

// Var Declarations

Code goes here

//Scanner Code

Code goes here

//check Code logic below

if ()

System.out.println("");

else if ()

System.out.println("");

else if ()

System.out.println();

Expected Output

Secret number is 50

Enter a guess: 50

Your guess is 50 Your guess is correct. Congratulations!

Secret number is 99

Enter a guess: 19

Your guess is 19

Your guess is smaller than the secret number.

Secret number is 72

Enter a guess: 89

Your guess is 89

Your guess is greater than the secret number.

User Daveman
by
5.1k points