00:01
Hello, welcome to this lesson.
00:01
In this lesson, we will write a java program and we'll let user enter value and we'll check whether the value is either divisible by five or six, but not both.
00:16
We will also check whether the value is divisible by both five and six.
00:22
And lastly, we'll check whether the number is divisible by either five or six.
00:34
Alright, so let's go on.
00:37
First of all, we can have a scanner so that we get user input.
00:43
So scanner is c, because in new scanner, we'll use the scanner object to get the user input.
00:53
So system .in, let me pass in that.
00:57
I will not have the second parameter declared.
01:03
Alright, then let me have, let me show on the screen what user will do.
01:10
So i'll say system .output.
01:12
I'll say enter your number.
01:18
So this is the number that we'll check whether it meets those conditions.
01:23
And now let's have an integer x, which would store the number into, so x is equals to the scanner, we invoke a method called nest int.
01:37
Alright, then this is what we do to check.
01:40
So say, if x is divisible by five and six, this will be our output.
02:01
The x is divisible by both five and six.
02:15
Alright, so let's implement this, we'll do if x divided by here, the only way x will be divisible by five and six is if x is divisible by 30.
02:41
Alright, so we say x mode 30 equals to zero, if we divide the x by 30, and the remainder is equals to zero, so here we are using the module.
02:57
So if x mode 30 is equals to zero, then it means that x is divisible by six, not divisible by five.
03:05
Conversely, we can check whether it is divisible by five and divisible by six.
03:12
But the short way of doing this is to check whether x is divisible by 30.
03:19
So if this is the case, new system .output.
03:23
We'll say this value x, which will actually put in the real value.
03:33
So it's divisible by both five and six.
03:43
Alright, so you also check else if so use the else condition to check if it is either divisible by five and no six, or six and no five, then this output will print...