Explore BrainMass

Explore BrainMass

    C++ program to determine if 3 numbers form a triangle

    This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

    Write a C++ program that reads in three integers representing line lengths, and determines if the three line segments form a right triangle. If it is not a right triangle, is it a valid triangle. Allow the three numbers to be input in any order. An input number 'n' will be in the range [1,5000]. The program should read the data from a file called triangleFile.dat and then write the results into an output file.

    Attached Word document (named as TriangleFile.dat) contains following test data.

    3 4 5
    55 25 25
    20 48 52
    123 345 299
    2002 4001 1050
    441 588 735
    4999 4999 4999
    648 702 270
    100 200 500
    88 50 60
    72 120 48
    75 60 45
    1000 50 1100

    © BrainMass Inc. brainmass.com June 4, 2020, 12:58 am ad1c9bdddf
    https://brainmass.com/computer-science/cpp/program-determine-numbers-form-triangle-371105

    Attachments

    Solution Preview

    Please find attached an implementation (371105.cpp) that reads the number triplets from input file "triangleFile.dat" and writes the ...

    Solution Summary

    The implementation assumes fair and valid input, that is, input numbers are positive integers and the count of numbers in input file is a multiple of 3.

    $2.19

    ADVERTISEMENT