Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Transactions On Large Scale Data And Knowledge Centered Systems Xxviii Special Issue On Database And Expert Systems Applications Lncs 9940

Authors: Abdelkader Hameurlain ,Josef Kung ,Roland Wagner ,Qimin Chen

1st Edition

3662534541, 978-3662534540

More Books

Students also viewed these Databases questions

Question

What is management growth? What are its factors

Answered: 1 week ago

Question

Develop clear policy statements.

Answered: 1 week ago

Question

Draft a business plan.

Answered: 1 week ago

Question

Describe the guidelines for appropriate use of the direct plan.

Answered: 1 week ago