#include <iostream>
#include <ctime>
#include "queue.h"
usingnamespace std;
int main(){
Queue car_wash;
int NO_HOURS;
cout << "How many hours would you like this car wash simulator to simulate?" << endl;
cin >> NO_HOURS;
for( int j = 0; j < NO_HOURS; j++ ){
car_wash.POT( car_wash.car_per_hr() );
}
car_wash.FREQ();
system( "PAUSE" );
getchar();
return 0;
}
For some reason though, everytime I call the car_per_hr() function, the probability just stays the same. It's output is always locked to the same thing it had to begin with.
What am I doing wrong?
Additional code can be provided if this is not sufficient.
I assume you mean all the numbers for a specific run are the same. The number will vary between individual runs, right?
You are reseeding the random number generator every time you call car_per_hr(). The multiple calls will all very likely be within the same clock second, so srand will reseed with the same value each time.
Instead of calling srand in the car_per_hr() function, call it in main(), say in line 11.