Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please write in C++ 1. Given a data set with 1000 TemperatureReading objects, count and print out the number of data entries for the city
Please write in C++
1. Given a data set with 1000 TemperatureReading objects, count and print out the number of data entries for the city "Seattle". 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()); } std::cout << data << " "; // TODO: print out the number of items in data that correspond to 'Seattle' }
Sample Output:
... Temp(id='997', city='Portland', value='2.30648'), Temp(id='998', city='Seattle', value='26.6842'), Temp(id='999', city='New York', value='21.7007'), ] There are 65 entries for 'Seattle'
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started