Hello. It's me again. I'm experimenting with random generators. I would like to generate a random number between 0 and 1. This will be multiplied with reliabilityOne to output a boolean value of either true or false. However, I cannot get the function to work properly. Any help would be greatly appreciated. The program keeps outputting a value of 1.
Your problem seems to be in isComponentWorking
1. rand() is always greater than 0, so randomNumber is always 1.
2. randomNumber is never used
3. http://www.cplusplus.com/reference/cstdlib/rand/ specifies that rand returns an integer. When multiplied with a double it is very rarely exactly 0 or exactly 1, so most of the time isPlworking is just what your default compiler puts out
Two other small observations:
1. instead of <stdlib.h> use <cstdlib>
2. the code between lines 57 and 69 can be replaced by something simpler:
1 2 3
overallReliability = analyticalReliabilityOne;
if (analyticalReliabilityTwo <= overallReliability) overallReliability = analyticalReliabilityTwo;
if (analyticalReliabilityThree <= overallReliability) overallReliability = analyticalReliabilityThree;