The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 402 Weeks Ago, 6 Days Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
Write a C++ program that will:
ask the user for the name of the data file
open the data file
if the file fails to open, print an error message and repeat step 1
Skip the first line of the data file
While: read three points
Use a function to calculate the length of each side of the triangle
Use a second function to calculate the area of the triangle
Print the three points and the area of the triangle
After all points have been read.Report
the three vertices for each triangle
the area of each triangle
The maximum area
The minimum area
The average area
Note: Round all output to two decimal places.
Sample Data File:
x1 y1 x2 y2 x3 y3 86.57 97.74 16.27 47.14 5.57 36.95 83.07 37.27 74.59 45.43 80.38 5.55 49.46 1.98 26.96 71.79 24.76 75.23 73.33 79.8 44.08 27.19 55.64 82.46 14.36 16.34 87.6 67.82 68.09 42.36 80.36 35.02 79.34 83.45 97.24 54.76 0.26 47.91 45.63 84.43 35.77 85.37 36.37 84.55 15.53 16.56 40.00 75.43 5.06 65.94 97.1 78.75 95.36 14.89 11.43 65.43 82.28 38.94 17.64 71.06 98.23 2.38 24.89 1.87 72.43 3.90
Sample Output:
Enter name of data file: BadFileName ERROR: Bad File Name Enter name of data file: points.txt ( 86.57, 97.74) ( 16.27, 47.14) ( 5.57, 36.95) area = 87.47 ( 83.07, 37.27) ( 74.59, 45.43) ( 80.38, 5.55) area = 145.47 ( 49.46, 1.98) ( 26.96, 71.79) ( 24.76, 75.23) area = 38.09 ( 73.33, 79.80) ( 44.08, 27.19) ( 55.64, 82.46) area = 504.24 ( 14.36, 16.34) ( 87.60, 67.82) ( 68.09, 42.36) area = 430.16 ( 80.36, 35.02) ( 79.34, 83.45) ( 97.24, 54.76) area = 418.82 ( 0.26, 47.91) ( 45.63, 84.43) ( 35.77, 85.37) area = 201.37 ( 36.37, 84.55) ( 15.53, 16.56) ( 40.00, 75.43) area = 218.43 ( 5.06, 65.94) ( 97.10, 78.75) ( 95.36, 14.89) area = 2927.69 ( 11.43, 65.43) ( 82.28, 38.94) ( 17.64, 71.06) area = 281.69 ( 98.23, 2.38) ( 24.89, 1.87) ( 72.43, 3.90) area = 62.32 ( 50.80, 88.38) ( 54.16, 5.48) ( 61.23, 30.76) area = 335.52 ( 26.44, 67.45) ( 26.13, 60.52) ( 77.85, 74.54) area = 177.04 ( 47.95, 64.25) ( 56.55, 15.78) ( 11.84, 97.85) area = 730.65 ( 96.77, 96.67) ( 92.07, 8.41) ( 33.12, 33.39) area = 2660.17 ( 73.31, 33.52) ( 17.07, 59.48) ( 22.70, 46.30) area = 297.54 Maximum area = 2927.69 Minimum area = 38.09 Average area = 594.79
Three files:
main, function prototype and function file
Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll