00:01
In this problem, we are going to ask the user to enter two numbers.
00:04
We are going to display the first number and then every increment of five after that up to and including the second number.
00:11
So i've already created a java program with the main method.
00:14
And the first thing i'm going to do is i'm going to create a scanner object called input.
00:19
And this is going to allow me to get user input, allow the user to type in numbers.
00:24
So we'll set it equal to a new scanner and then in parentheses, system .n.
00:29
And system .in just means the user is typing the input.
00:32
The next thing we'll do is we'll ask the user to enter two numbers.
00:36
So we'll give them a system .out.
00:40
Printline and we will say, please enter two numbers.
00:49
And then we'll create variables to hold the numbers.
00:51
So we'll say end first for the first number.
00:54
And of course you can call it whatever you want, but first and second makes sense.
00:57
And we always try to use variable names that make sense.
01:00
And so we'll use our scanner, which is input.
01:04
Dot next int.
01:06
And this will basically wait until the user types in a number and presses enter.
01:10
And we'll do the same thing for the second number.
01:13
Int second equals input.
01:16
Nextint.
01:17
So now the user will be able to type in their two numbers.
01:21
And what we want to do here is we want to display the first number and all of the increments of five.
01:27
And there's a couple of different ways we could do that.
01:29
But a really good way is going to be to use a while loop.
01:33
So we'll start out by saying while.
01:35
And while basically means that we're going to take a process and repeat it over and over again.
01:41
And we want to loop as long as the first number is smaller than the second number.
01:50
And we want to be really specific here if we want less than or less than or equal to.
01:54
And the problem specifies that we want to include the second number.
01:57
So if we get to the second number exactly, we still want to display that.
02:02
So we want less than or equal to second.
02:04
And then a set of curly brackets, which will define what gets repeated.
02:10
And so what we want to do is we want to print the number.
02:13
So system dot out.
02:15
Dot print line.
02:18
And the problem specifies that we're going to put a space after it.
02:22
And actually, because we're doing that, we don't want a print line.
02:25
We want to keep everything on the same line according to the directions.
02:27
So we'll just say system .out.
02:29
Print the first number and a space.
02:33
And then we're going to put one more line...