Fellow C++ citizens,
I am very new to C++ and am trying to do the following:
I want to transform a chart into code. Basically, the chart serves as a diagnostic reference. For an example, if a certain condition is below a certain value, there would be a few issues associated with this condition. The diagnosis will run through a series of conditions, and the number of the time that the problems (only 9 possible) appear is tallied up. Here is the code so far:
#include <cstdlib>
#include <iostream>
using namespace std;
int main ()
{
// Declaring Variables
int ambient_temp;
int condenser_temp;
int normal_cond_temp;
int cond_outlet_temp;
int condenser_subcool;
int evap_temp;
int normal_evap_temp;
int air_entr_evap;
int evap_superheat;
int normal_superheat;
int evap_outlet_temp;
int sightglass;
int problem[9];
// Determining Condensing Temperature
cout << "Please enter Ambient Temp: ";
cin >> ambient_temp;
cout << "Please enter Condensing Temperature: ";
cin >> condenser_temp;
normal_cond_temp = ambient_temp + 30;
if (condenser_temp > normal_cond_temp + 10)
{
problem[1] = 0;
problem[2] = 0;
problem[3] = 0;
problem[4] = 0;
problem[5] = 0;
problem[6] = 1;
problem[7] = 1;
problem[8] = 1;
problem[9] = 1;
}
else if (condenser_temp < normal_cond_temp - 10)
{
problem[1] = 1;
problem[2] = 1;
problem[3] = 1;
problem[4] = 1;
problem[5] = 1;
problem[6] = 0;
problem[7] = 0;
problem[8] = 0;
problem[9] = 0;
}
else
{
problem[1] = 0;
problem[2] = 0;
problem[3] = 0;
problem[4] = 0;
problem[5] = 0;
problem[6] = 0;
problem[7] = 0;
problem[8] = 0;
problem[9] = 0;
}
// Determining Condenser Subcooling
cout << "Please enter Condensing Outlet Temp: ";
cin >> cond_outlet_temp;
condenser_subcool = condenser_temp - cond_outlet_temp;
if (condenser_subcool > 20)
{
problem[1] += 0;
problem[2] += 1;
problem[3] += 0;
problem[4] += 0;
problem[5] += 0;
problem[6] += 1;
problem[7] += 0;
problem[8] += 1;
problem[9] += 1;
}
else if (condenser_subcool < 5)
{
problem[1] += 0;
problem[2] += 0;
problem[3] += 1;
problem[4] += 0;
problem[5] += 0;
problem[6] += 0;
problem[7] += 0;
problem[8] += 0;
problem[9] += 0;
}
else
{
problem[1] += 1;
problem[2] += 1;
problem[3] += 0;
problem[4] += 1;
problem[5] += 1;
problem[6] += 0;
problem[7] += 1;
problem[8] += 0;
problem[9] += 0;
}
// Determining Evaporator Temperature
cout << "Please enter Air Entry Evap Temp: ";
cin >> air_entr_evap;
cout << "Please enter Evaporator Temp: ";
cin >> evap_temp;
normal_evap_temp = air_entr_evap - 35;
if (evap_temp > normal_evap_temp + 10)
{
problem[1] += 0;
problem[2] += 0;
problem[3] += 0;
problem[4] += 1;
problem[5] += 0;
problem[6] += 0;
problem[7] += 1;
problem[8] += 1;
problem[9] += 1;
}
else if (evap_temp < normal_evap_temp - 10)
{
problem[1] += 1;
problem[2] += 1;
problem[3] += 1;
problem[4] += 0;
problem[5] += 1;
problem[6] += 1;
problem[7] += 0;
problem[8] += 0;
problem[9] += 0;
}
else
{
problem[1] += 0;
problem[2] += 0;
problem[3] += 0;
problem[4] += 0;
problem[5] += 0;
problem[6] += 0;
problem[7] += 1;
problem[8] += 1;
problem[9] += 1;
}
// Determining Evaporator Superheat
cout << "Please enter Evaporator Outlet Temp: ";
cin >> evap_outlet_temp;
evap_superheat = evap_temp - evap_outlet_temp;
normal_superheat = 15;
if (evap_superheat > normal_superheat + 5)
{
problem[1] += 0;
problem[2] += 1;
problem[3] += 1;
problem[4] += 1;
problem[5] += 1;
problem[6] += 1;
problem[7] += 0;
problem[8] += 0;
problem[9] += 0;
}
else if (evap_superheat < normal_superheat - 5)
{
problem[1] += 1;
problem[2] += 0;
problem[3] += 0;
problem[4] += 0;
problem[5] += 0;
problem[6] += 0;
problem[7] += 1;
problem[8] += 1;
problem[9] += 1;
}
else
{
problem[1] += 1;
problem[2] += 0;
problem[3] += 0;
problem[4] += 0;
problem[5] += 0;
problem[6] += 0;
problem[7] += 1;
problem[8] += 1;
problem[9] += 1;
}
// Determining Sight Glass Issues
cout << "Is Sight Glass 1.Full or 2.Bubbling: ";
cin >> sightglass;
if (sightglass == 1)
{
problem[1] += 1;
problem[2] += 1;
problem[3] += 0;
problem[4] += 1;
problem[5] += 1;
problem[6] += 0;
problem[7] += 1;
problem[8] += 1;
problem[9] += 1;
}
else
{
problem[1] += 0;
problem[2] += 0;
problem[3] += 1;
problem[4] += 0;
problem[5] += 1;
problem[6] += 1;
problem[7] += 0;
problem[8] += 0;
problem[9] += 0;
}
cout << endl;
// System Pause
system("PAUSE");
return EXIT_SUCCESS;
}
However, now I run into the issue of extracting useful information from this system. I want to know which problem came up most frequently. To do this, I need to be able to identify the maximum value of the element in the array and its associated index. In addition, I also want to be able to label the problems with strings as opposed to the array index number. What can I do?
Thank you so much for your time!