Advertisement
Guest User

home work

a guest
Mar 28th, 2015
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.96 KB | None | 0 0
  1.  Write a program that reads 3 points and calculate the area formed by these three points. If the triangle cannot be formed, indicate that the triangle cannot be formed.
  2. A possible run may look like:
  3. Enter three points: 1 1 1 4 5 1
  4. The area formed by (1.00, 1.00), (1.00, 4.00), and (5.00, 1.00) is 6.00.
  5. Hint:
  6.  1. Math.sqrt
  7.  2. The distance between two points (x1, y1) and (x2, y2) is sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)).
  8.  3. Suppose a triangle with 3 sides: a, b, c. s = (a + b + c)/2. The area of the triangle is
  9.        sqrt(s * (s - a) * (s - b) * (s - c)).
  10. Question 2:
  11. Read two points and calculate the line equation formed by these two points in the form of ax + by = c. A possible run may look like:
  12.  Enter two points: -4 6 8 -3
  13.  The line is 3.000x + 4.000y = 12.000
  14.  Enter two points: 1 1 1 1
  15.  The line cannot be formed.
  16.  Hint: The line equation passing two points (a, b) and (c, d) is
  17.        (b - d)x + (c - a)y = a(b - d) + b(c - a).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement