Question: Code in C++ Given the following program which creates an array of 100 temperature readings, print out the city with the highest temperature reading. Also

Code in C++

Given the following program which creates an array of 100 temperature readings, print out the city with the highest temperature reading. Also print out the average temperature of "Houston".

Starter Code:

#include  #include  #include  #include  using namespace std::string_literals; struct CityTempReading { std::string city; double temperature; }; CityTempReading getNewReading(); int main() { std::array readings; for (auto i = 0; i < readings.size(); i++) { readings.at(i) = getNewReading(); } // TODO: print city with the hottest temperature reading // TODO: print out the average temperature of "Houston" } CityTempReading getNewReading() { static std::mt19937 rand{ std::random_device{}() }; static std::uniform_real_distribution temperatureRange{ 0.0, 110.0 }; static std::array cities = { "New York", "Los Angeles", "Las Vegas", "Denver", "Houston", "Atlanta", "Seattle", "San Francisco", "Boston", "Miami" }; static std::uniform_int_distribution cityRange{ 0, cities.size() - 1 }; return CityTempReading{ cities.at(cityRange(rand)), temperatureRange(rand) }; } 

Sample Output:

hottest temperature: Miami at 108.635 degrees Houston average: 55.0432 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!