// This is a version that I coded of the CS-071 Project 1 for the // Fall 2002 semester. // Nathaniel Guy, September 2002 // Basically I take a lot of trends and combine them into one program // that takes data and predicts the concentration by a set formula. // It's pluggy and chuggy, but the algorithm took some thinking. I // tried to make the program's operations as simple and straight-forward // as possible. #include int main(){ const float maxconcentration = 2100; float watertemp, salinity, light, nutrients; // data collection jive cout << "Welcome to the pseudo-nitzschia australis concentration " << "estimator." << endl; cout << "Given conditions in Monterey Bay, an estimation will be made " << "as to the probable" << endl << "concentration of the diatom." << endl << endl; cout << "Please input the average water temperature in degrees C: "; cin >> watertemp; cout << "Please input the water salinity in ppm: "; cin >> salinity; cout << "Please input the average amount of light in lumens: "; cin >> light; cout << "Please input the nitrate nutrients in mg/m^3: "; cin >> nutrients; // note on algorithm: for simplicity, I assumed that all factors were // equally important and affected the overall concentration by a factor // of 1/4. Further information and research would be necessary to make // user, but that might make the program in general less efficient and // it'd be a lot easier just to set constants for the ratio. Naturally, // this is left as an exercise to the reader. Also, I eventually ended // up utilizing a simple parabola to map the temperature curve; the // data seemed to be describing its behavior to be parabolic in nature. // below, adjusting of variables for the sake of the algorithm // since the functional effect of the water temperature is only in // place from 10 to 22 degrees C, I decided to seal those bounds: if (watertemp < 10) watertemp = 10; else if (watertemp > 22) watertemp = 22; // and thusly with the salinity, from 32 to 27 ppm: if (salinity < 32) salinity = 32; else if (salinity > 37) salinity = 37; // similarly with the light, which runs from 600 to 1350 lumens: if (light < 600) light = 600; else if (light > 1350) light = 1350; // and finally the same with the nutrients, from 0 to 25 mg/m^3: if (nutrients < 0) nutrients = 0; else if (nutrients > 25) nutrients = 25; // now to the calculation of the actual result: float concentration = maxconcentration * /* temp. factor*/ ((-.027777) * (watertemp - 16) * (watertemp - 16) + 1) * /* salinity factor */ ((37 - salinity) / 5) * /* light factor */ ((light - 600) / 750) * /* nutrients factor */ (nutrients / 25); cout << "We estimate the amount of pseudo-nitzschia australis " << "(in mg/m^3) to be: " << concentration << endl; return 0; }