Question: Help with my code? Error code E0441 appears, Line 50, has a problem with std::array cities line? Using visual studio 2022. Thank you #include #include
Help with my code? Error code E0441 appears, Line 50, has a problem with "std::array cities" line? Using visual studio 2022. Thank you
#include
using namespace std::string_literals;
struct CityTempReading { std::string city; double temperature; };
CityTempReading getNewReading();
int main() { std::array
// Find the city with the highest temperature reading double highestTemp = 0; std::string hottestCity; for (const auto& reading : readings) { if (reading.temperature > highestTemp) { highestTemp = reading.temperature; hottestCity = reading.city; } } std::cout << "hottest temperature: " << hottestCity << " at " << highestTemp << " degrees" << std::endl;
// Calculate the average temperature of Houston double houstonTotal = 0; int houstonCount = 0; for (const auto& reading : readings) { if (reading.city == "Houston") { houstonTotal += reading.temperature; houstonCount++; } } double houstonAverage = houstonTotal / houstonCount; std::cout << "Houston average: " << houstonAverage << std::endl; }
CityTempReading getNewReading() { static std::mt19937 rand{ std::random_device{}() }; static std::uniform_real_distribution
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
