LAB 06A - TRIANGLE SRUCTS

Concepts

To gain practice with structs, we will use a struct to represent a Triangle. The user will be able to enter the length of sides for two triangles. Our program will then calculate if the two triangles are equivalent via SSS (side, side, side) similarity.

Instructions

A starting template has been provided for you in Lab06Amain.cpp. BE WARNED! This template will not compile out of the box; you must complete the TO DO items before it will fully work. Below are short instructions for each TO DO item.

  1. TO DO #1:
    Define a struct that describes a Triangle, appropriately named Triangle. The struct should contain the necessary information to store the lengths of the three sides of a triangle.

  2. TO DO #2:
    Declare a function named HaveUserEnterTriangle. This function should take a Triangle variable as a paramenter passed by reference. The function has no return value. The function should prompt the user to enter the length for each side of the triangle and store the entered values onto the Triangle parameter passed into the function.

  3. TO DO #3:
    Declare a function named OrderTriangleSides. This function should take a Triangle variable as a parameter passed by reference. The function has no return value. The function should sort the lengths of the triangle from smallest to largest. After the function completes, side1 of the triangle should have the shortest side length, side2 should have the middle side length, and side3 should have the longest side length.

  4. TO DO #4:
    Declare a function named AreTrianglesEquivalent. This function should take two Triangle variables as parameters, both passed by value. The function will return a boolean. The function must compare the ratios of like sides of the triangles to determine if the two are equivalent (remember geometry? Side-Side-Side similarity). The function will return true if the two triangles are similar. Otherwise, it returns false.

You may assume that the user will enter valid sides that form a triangle, so you do not have to test if the sides are all positive and/or form a triangle.

Hints

We recommend that you create the Triangle struct first and then create a function stub for each function so your program can compile.

Once your program successfully compiles and can execute, then start filling in each function one at a time in the order the TO DOs are listed.

Use an incremental build strategy. Once TO DO #1 is completed and tested, get TO DO #2 working properly. Once TO DO #2 is completed and tested, move on. And so forth.