00:01
In this video, we will create a program that randomly generates three single digit integers and displays a question asking the user to add all three digits.
00:09
We are asked to revise the program addition to quiz .java, which generates two integers for addition.
00:16
After the user types the answer, the program will display a message indicating the answer is correct or incorrect.
00:21
I've already defined our class as well as the main method within it.
00:24
I've also imported java .utl .scanter since we know we'll be taking user input.
00:29
We can go ahead into our main method and declare and randomly generate three single dishes.
00:34
We can do this just as is done in addition quiz .java.
00:42
So we'll declare the first one.
00:45
We'll want to cast this number to an integer since they used system.
00:50
Thought current time, milliseconds.
01:01
And then mod 10.
01:12
Similarly, we can copy the second digit from addition quiz .java.
01:20
Call this n2.
01:25
We can integer divide by 7 first, and then mod 10.
01:32
Now we'll want to add our own for this program.
01:34
We must add a third integer number.
01:38
So n3 equals, again, we're going to want to cast its int.
01:43
Oops, we can integer divide by 9 for this one.
01:52
And then mod 10.
01:54
So now we have our three integer numbers.
01:58
Now we're going to want to record the answer so we can declare an int.
02:03
Answer equals n1 plus n2 plus n3.
02:07
This will be the sum.
02:09
The correct answer.
02:12
At this point, we're going to want to create a new scanner object called input by calling scanner with the argument system .in, which allows keyboard input to be read from inside our java application.
02:41
Now we'll want to prompt the user to enter their answer for the addition of these three digits...