You could define some extra variables, such as
double minTemp
and
double maxTemp
.
At the start, before reading any data from the file, give these suitable initial values which you know will later be replaced.
|
double minTemp = +1000000; // give the minimum a very big value
|
Then inside the loop where you have read the data for each planet, put something like this:
1 2 3 4
|
if (fahrenheit < minTemp)
{
minTemp = fahrenheit;
}
|
Since you will later want to print the corresponding planet name, you could also define a new variable
string coldName;
then each time the value of
minTemp
is updated, store the name of the planet too.
Then later, you simply print these results, no if conditions are needed, no for loop, just print them out.