// Zeinalipour-Yazti Demetrios // csyiazti // cs10xx - // Lab Sec#24 // lab6 /* Triangle Calculations * This program finds the missing information of a right triangle many times. * A) Input: length of side X, angle A1 * B) Restrictions: inputs must be positive * C) Output: side Y, hypotenuse Z, Angle A2. * D) Pythagorean Theorem.==> * Z^2 = X^2 + Y^2 * */ #include #include #define PI 3.14159265 /* This function asks the user to input the value: valuename[] repetively until a * correct (>0) value is given. It then returns this value */ double getValue(char valuename[]) { /* defining local scope variables*/ double value; /* Getting the value */ while (true) //start while1a { cout << "\nPlease type in the (positive) \"" << valuename << "\" : "; cin >> value; if (value>0) { break; } else { cout << "Error# - The value you entered is not a positive integer: " << endl; } } //end while1a return value; } /* This function calculates the other angle */ double calculateAngle(double angle1) { return (90-angle1); } /* This function calculates the the other leg of the right triangle, using * the Pythagorean Theorem. */ double calculateY(double x, double angle1) { return ( tan(angle1*PI/180) * x); } /* This function calculates the length of the hypotenuse with the * Pythagorean Theorem. */ double calculateZ(double x, double y) { double z = sqrt(x*x + y*y); return z; } /* This procedure outputs all the values related to the right triangle */ void printOut(double a1, double a2, double x, double y, double z) { cout << "Angle 1: " << a1 << endl << "Angle 2: " << a2 << endl << "Length of X: " << x << endl << "Length of Y: " << y << endl << "Length of Z: " << z << endl; } /* This procedure outputs graphically the triangle. */ void printTriangle(double x,double y) { double items_per_row = y / x; for (int i=0; i