00:01
Kind of like a random number generator.
00:02
And we're going to start off first by importing the correct libraries.
00:05
We're going to do import java .util .scanner.
00:10
And this is going to be responsible for our user inputs.
00:13
And then we're also going to import java .util .random.
00:18
And this is going to be responsible for our numbers, for random numbers that we get.
00:23
So here we can start off here.
00:25
We're going to make first a random variable object.
00:30
So we're going to make this new random.
00:33
And then from here, we're going to do an input.
00:36
Because we want the user to input a number at the very beginning.
00:41
So we're going to have new scanner.
00:44
And it's going to be system .in.
00:50
Perfect.
00:52
And then from here, we're going to make a random number using this random object here.
01:01
So what we're going to do is we're going to do int num to press.
01:05
And this is going to be equal to the random.
01:07
Next int.
01:09
And this is going to be from the value to 0 to 100.
01:13
So we have to do this intermediary because it's exclusive.
01:17
So we're going to drop that in there.
01:19
Exclusive.
01:22
So we have to include an additional version of it.
01:25
Perfect.
01:27
Oh, and i forgot my semicolon.
01:30
Do not forget your semicolon if you're writing in java.
01:32
And then from there, we're going to do int number of tries.
01:37
Because we want to see how many tries it takes the user to get this answer.
01:42
And we're going to have a boolean.
01:44
We're going to call it correct guess.
01:47
And we're going to set this to false at the very beginning because the user hasn't used the word yet.
01:51
So we don't know.
01:53
Ok.
01:53
Perfect.
01:54
And then we're going to ask the user.
01:55
And i'm actually going to use this system .out .println.
01:58
And we're going to ask the user, guess a number between 1 and 100.
02:06
Perfect.
02:07
And from here, we're not going to get anything extra.
02:14
So perfect.
02:17
And now we're going to use a while loop.
02:18
The reason we're going to use a while loop is because we want this to keep going until they have guessed the number correctly.
02:23
So we're going to call it correct guess.
02:27
So while correct guess is false, we're going to keep asking the user.
02:32
So we're going to prompt the user.
02:33
And i'm going to copy this line here.
02:35
We're going to keep prompting the user.
02:36
Enter the number you want to guess.
02:38
So enter your guess.
02:42
Perfect...