I'm trying to make a thermometer that can show when the temperature goes out of the range of 17 and 24 degrees,
when it goes below 17 degrees i want it to count how many times it goes below 17 degrees and how may times it goes above 24 degrees as well.
any tips to help improve my code are welcome, as when i run this code it constantly shows temperature below 17 and wont stop
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
float index;
float random_temp = 0;
float total = 0;
srand (time (NULL));
int lowest=12, highest=28;
int range=(highest-lowest)+1;
cout << " Temperature Vaules " << "\t" << " Sum of Temperature Values " << endl;
for (index = 1; index <= 40; index++)
{
random_temp = lowest+int(range*rand()/(RAND_MAX + 1.0));
while(random_temp != 17,18,19,20,21,22,23,24)
{
if (( random_temp >= 12 || random_temp < 17 ))
{
while( random_temp >= 12 || random_temp < 17 )
{
cout << " Temperature below 17 Degrees Celsius " << endl;
}
}
else if (( random_temp > 24 || random_temp <= 28 ))
{
while( random_temp > 24 || random_temp <= 28 )
{
cout << " Temperature above 24 Degrees Celsius " << endl;
}
}
}
total = total + random_temp;
cout << "\t" << random_temp << "\t" << "\t" << "\t" << total << endl;
}
system( "pause");
return 0;
}