Question: Write a program that (1) uses a random number generator to generate random x, and y coordinates of the vertices of a triangle, in the

Write a program that (1) uses a random number generator to generate random x, and y coordinates of the vertices of a triangle, in the range 0 to +99 for each x and y coordinate. (2) calculate each edge of the triangle from those coordinates by using Pythagoras theorem. (3) check that that triangle is valid by performing a test. The test is that a triangles sides are valid if the sum of every pair of two edges is greater than the remaining edge (edge1+edge2>edge3 and edge1+edge3>edge2 and edge3+edge2>edge1). (4) If the triangle is not valid generate a new triangle by repeating step (1)- (2)- and (3) as many times as needed until you get a valid triangle. (5) Once you have a valid triangle calculate the area of the triangle using Herons Formula given below, and print the co-ordinates, sides and area.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!