00:01
Hello students, here we have to write the program that prompt the user to enter the point x ,y and check whether the point is within the rectangle centered at 0 ,0 with width 10 and height 5.
00:13
So, here width is given 10, so this one is 10, this width and height is given here 5.
00:22
So, width is 10 and height is 5.
00:26
So, for example, if i take the 2 ,2 point, it is inside the rectangle but if i take 6 ,4 it is not in the rectangle because it becomes 5, so this is not inside the rectangle.
00:39
So, this point is outside and this point is inside.
00:45
So, we have to now write the program for this.
00:50
So, we have to write two classes here coordinates .java and test coordinates .java.
00:57
So, first coordinates .java.
01:00
So, here coordinates .java public class coordinates here i am taking x and y which the user will enter so its type is double.
01:10
Public coordinates, so here coordinates constructor which taking the arguments x and y so these are allocated to the class data.
01:21
These values will come from the user.
01:23
Now boolean type is in rectangle or not.
01:27
So, we will first find is in rectangle or not.
01:32
The point are in the rectangle or not.
01:34
So, here double half width we have to do the half because it's on the origin.
01:41
That's why we have to divide the width and divide the height.
01:45
So, these are the double type data and i have taken the new variable half width and half height where it will say store the half of value of the coordinates return math .absolute here i am taking the absolute value that's why i am this value this function is in math library.
02:06
So, i am taking this and so i am checking if absolute value of x is less than or equal to half width and absolute value of y is less than or equal to half width.
02:19
So, it will return this in this case.
02:23
So, this is the way and now public string to string this will return the point x and y.
02:32
So, here now second method after finding that the coordinates are inside or not given coordinates after this test coordinate here i am testing...