Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Write a program in C++ 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Information Modeling And Relational Databases

Authors: Terry Halpin, Tony Morgan

2nd Edition

0123735688, 978-0123735683

Students also viewed these Databases questions