Good day! Please help me figure out where the error is in the problem.
Task:
Everyone knows that gardeners are strange people, almost the same as programmers. They build their country houses where it is not clear, and they grow there is not clear that it is not clear why. And how they get there is another story: who is on the bus, who is on the train, who is on the car, well, someone does walk on foot from home to the station. So you should not be surprised if you suddenly find out that a certain gardening partnership is located on the island, and summer residents get to it by plane. Yes, and on this island may not be the landing strip, so you can land on the island, only by jumping with a parachute (we really do not consider how they return home from cottages). Consider this unique case. The pilot always tries to disembark the parachutists in such a way that the summer residents land as close as possible to their rectangular areas. The pilot is interested to know: how many summer residents land on their plots? Help him solve this problem!
Input data:
The first line of the input file INPUT.TXT contains a natural number N (1 ≤ N ≤ 1000) - the number of summer residents, followed by N lines, each of which describes the coordinates of each summer resident and its site: X, Y, X1, Y1, X2, Y2, X3, Y3, X4, Y4 where X, Y are the touchdown coordinates of the parachutist X1, Y1, X2, Y2, X3, Y3, X4, Y4 are the coordinates of a rectangular section on a plane, indicated sequentially. All coordinates are integers not exceeding 50000 in absolute value.
Output:
In the output file OUTPUT.TXT you need to display the number of summer residents who landed on their site. Hit on the border of the site is considered to hit the site.
I decided to connect the landing point of the summer resident with the vertices of the rectangle and lay down the areas of the resulting four triangles. Next, calculate just the area of the rectangle and if it coincides with the sum of the triangles, then the summer resident got into his area. On, as a result, the program displays the numbers of all summer residents. Please help me figure out what's wrong.
Here is the program:
import java.io.File; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Scanner; import static javafx.scene.input.KeyCode.N; public class T_12 { static int N; PrintWriter pw; public static void main(String[] args) throws Exception { new T_12().run(); } public void run() throws Exception { Scanner sc = new Scanner(new File("C:\\Users\\sbeskhmelnitskiy\\Desktop\\input.txt")); pw = new PrintWriter(new File("C:\\Users\\sbeskhmelnitskiy\\Desktop\\output.txt")); N = sc.nextInt(); //Создаю дачников и считываю их координаты for (int i = 0; i < N; i++) { Human h = new Human(); for (int t = 0; t < 5; t++) { for (int j = 0; j < 2; j++) { h.coord[t][j] = sc.nextInt(); } } //Передаю Дачника и его номер(для его вывода в файл если он попал к себе), на проверку. check_human (h, i); } pw.close(); } public void check_human(Human hum, int num) throws Exception { double areat = 0, areas = 0; //Считаю площадь четырех треугольников(соеденил точку приземления с вершинами) for (int i = 0; i < 4; i++) { if (i < 3) { areat += 0.5 * ((hum.coord[0][0] - hum.coord[i + 2][0]) * (hum.coord[i + 1][1] - hum.coord[i + 2][1]) - (hum.coord[i + 1][0] - hum.coord[i + 2][0]) * (hum.coord[0][1] - hum.coord[i + 2][1])); } else { areat += 0.5 * ((hum.coord[0][0] - hum.coord[1][0]) * (hum.coord[i + 1][1] - hum.coord[1][1]) - (hum.coord[i + 1][0] - hum.coord[1][0]) * (hum.coord[0][1] - hum.coord[1][1])); } } //Считаю площать прямоугольника(разбил его на два треугольника и посчитал их площадь) areas = 0.5 * ((hum.coord[1][0] - hum.coord[3][0]) * (hum.coord[2][1] - hum.coord[3][1]) - (hum.coord[2][0] - hum.coord[3][0]) * (hum.coord[1][1] - hum.coord[3][1])); areas += 0.5 * ((hum.coord[3][0] - hum.coord[1][0]) * (hum.coord[4][1] - hum.coord[1][1]) - (hum.coord[4][0] - hum.coord[1][0]) * (hum.coord[3][1] - hum.coord[1][1])); if (areas == areat) pw.println (num+1); } } public class Human { double [][] coord = new double [5][2]; } The output is "1 2 3", and should only "2". areas and areat are the same, although they must be different except for the second summer resident. What is the problem please tell me.

... получаются одинаковыми, хотя кроме второго дачника должны быть разными.What exactly is the result that is not what you expected? If you determine the specific incorrect result, then the question will be reduced to the formпочему эта строка дает результат X, хотя должна YThis question will be answered faster. - default locale