Question: Please write in C++ 4. Given a data set with 1000 TemperatureReading objects, sort the objects by temperature from least to greatest and print out

Please write in C++

4. Given a data set with 1000 TemperatureReading objects, sort the objects by temperature from least to greatest and print out the sorted list. You may not use a raw loop to solve this problem.

Starter Code:

#include  #include  #include  #include  #include "TemperatureReading.h" template std::ostream& operator<<(std::ostream& out, std::vector& values) { out << "[ "; for (const auto& value : values) { out << "\t" << value << ", "; } out << "]"; return out; } int main() { std::vector data; for (auto i = 0; i < 1000; i++) { data.push_back(generateRandomTemperatureReading()); } // TODO: sort the elements by temperature and print out the result } 

Sample Output:

[ Temp(id='942', city='Los Angeles', value='0.0278116'), Temp(id='513', city='Boston', value='0.100219'), Temp(id='577', city='San Diego', value='0.110175'), ... Temp(id='325', city='Houston', value='39.8376'), Temp(id='866', city='Las Vegas', value='39.8488'), Temp(id='839', city='Atlanta', value='39.8859'), ]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To sort the TemperatureReading objects by temperature from least to greatest without using a raw loo... View full answer

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!