00:01
In this video, we are going to create a program that calculates the distance between two points.
00:05
I've written the distance formula on the upper right hand corner for a reminder.
00:10
I've also jotted down to examples, both that i've ran with the code word.
00:18
I'm going to write right now.
00:19
So looking at the code, i've already defined our class as well as the main method within it.
00:25
I've also imported java .util .scanner, since we know we'll be taking user input for the the points as well as java .lang .m.
00:33
Since we see square in a square root in some terms in our distance formula.
00:39
So we can go ahead into the main method.
00:41
We can create a new scanner object, calling an input, and using the predefined object system.
00:53
.in as an argument because this represents the standard input stream.
00:58
The next thing we'll want to do is prompt the user to and enter two points.
01:03
So we can use system .out .print l .n and say enter the first point.
01:16
So after this, we will want to use the next double method of the scanner input and create a double x1.
01:38
So this method of the scanner class scans the next token of the input as a double and we'll store them as such.
01:47
Same thing with x y1 my mistake so this is going to be our first point next we're going to want to print the same thing again asking the user to enter the second point again it's going to be the same with storing the user input so we can do double x2 and y2 next we can compute the distance to do this, we can go by our formula.
02:41
So i'm basically making in the comment just to show you math .com.
02:49
So it's going to be x2 minus x1 squared, so to the two...