In Python Coding: Maximum Triangle Area. Write a text?based program that reads a set of points from a text file and outputs on the screen
In Python Coding:
Maximum Triangle Area. Write a text?based program that reads a set of points from a text file and outputs on the screen the area of the largest triangle that can be formed among all the possible combinations of three points. The maximum number of points in the file is 10. The format of the text file consists of one point per line where each point is described by a coordinate x,y consisting of two integer numbers x and y both between 0 and 100 separated by a coma and with no blank spaces in between. Example: a file with a set of four points would be as follows:
10,3 5,91 43,0 77,20
With this set of points you can form 4 different triangles (in general, from a set of n distinct points you can form
n!/(6(n-3)!) distinct triangles) as follows:
(1) 10,3 5,91 43,0 (area = 1444.5 square units)
(2) 10,3 5,91 77,20 (area = 2990.5 square units)
(3) 10,3 43,0 77,20 (area = 381 square units)
(4) 5,91 43,0 77,20 (area = 1927 square units)
The triangle with the largest area is the one formed by the points 10,3 5,91 and 77,20 (with an area of 2990.5 square units). There are methods to calculate the distance between two lines and the area of a triangle; you are free to use the method of your choice.
To run the program the user should type python maxtriangle, and then the program should ask the user to enter the name of the file containing the points.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started