Good Morning all:

I am new to programming and I have a homework assignment that is giving me some difficulty. The problem is the glass rod problem. Where you break a glass rod in 3 pieces an see if the pieces will for a triangle.

The main problem is how the professor wants the program written.

We have to write a main and three functions that do most of the work. I have my code written and it compiles but it returns erroneous answers. Here is my code, can anyone point me in the right direction to fixing it. Please

Code:#include <iostream> #include <cmath> #include <cstdlib> #include <ctime> #include <cstdlib> using namespace std; void doBreak (int & side1, int & side2, int & side3); bool attempts (int); void randomNumberGen (int & num1, int & num2); void main() { int count = 1; int tests = 1000000; double probability; int attempts; int triangle = 0; int val; srand (time(0)); do { triangle = triangle + attempts; count++; }while (count <= tests); probability = (triangle / tests) * 100; cout <<"The probability that the broken glass rod will form a triangle is" << probability <<"% \n"; } bool attempts (int) { int side1, side2, side3; doBreak (side1, side2, side3); if ((side1 + side2) > side3 && (side1 + side3) > side2 && (side2 + side3) > side1) { return true; } else { return false; } } void doBreak (int & side1, int & side2, int & side3) { int num1, num2; randomNumberGen (num1, num2); side1 = num1; side2 = (num2 - num1); side3 = 1000 - num2; } void randomNumberGen (int & num1, int & num2) { do { num1 = rand() % 999 + 1; num2 = rand() % 999 + 1; } while (!(num1 < num2)); }