Quadrants and Triangle Area


Submit solution

Points: 100
Time limit: 20.0s
Memory limit: 256M

Author:
Problem types
Allowed languages
Java 19

Read the coordinates of three points \((x_1, y_1)\), \((x_2, y_2)\) and \((x_3, y_3)\) on a plane. For each point, print which quadrant it is in. Then print the area of the triangle formed by the three points.

A point that lies on the x-axis or the y-axis (including the origin) does not belong to any quadrant.

The area of the triangle is:

\[Area = \frac{|x_1(y_2 - y_3) + x_2(y_3 - y_1) + x_3(y_1 - y_2)|}{2}\]

Input Specification

One line with six integers \(x_1\) \(y_1\) \(x_2\) \(y_2\) \(x_3\) \(y_3\), separated by spaces.

Output Specification

Print four lines.

  • Lines 1 to 3: for point \(k\) (\(k\) = 1, 2, 3), print Point k: Quadrant q, where \(q\) is 1, 2, 3 or 4. If the point is on the x-axis or the y-axis, print Point k: Axis instead.
  • Line 4: print Area: followed by the area, rounded to 1 decimal place.

Sample Input 1

-2 3 -4 -1 3 -2

Sample Output 1

Point 1: Quadrant 2
Point 2: Quadrant 3
Point 3: Quadrant 4
Area: 15.0

Sample Input 2

0 0 3 0 0 3

Sample Output 2

Point 1: Axis
Point 2: Axis
Point 3: Axis
Area: 4.5

Comments

There are no comments at the moment.