From the course: Code Clinic: C++

Solution overview: Weather statistics - C++ Tutorial

From the course: Code Clinic: C++

Start my 1-month free trial

Solution overview: Weather statistics

- [Instructor] I'll start with a high-level overview and demonstration of my C++ solution to the Weather Statistics Challenge. The data files for this Challenge are located in the exercise files, chapter one resources folder. The data is contained in four separate text files representing weather data from 2012 to 2015. Navigating back up one level and then into the solution folder, you'll find the source files for my solution. WeatherStatisticsMain.cpp contains the programs main function, which simply handles the user input and output on the command prompt. The real meat of the program is contained within WeatherStatistics.cpp and its corresponding header, which I'll be covering in more detail. I've also included a make file. So, to compile this program I'll open a command prompt in this directory by typing cmd into the navigation bar. Then type make and press enter. This program doesn't have any dependencies to link beyond the standard template library. So, it's pretty easy to build. To run the program, I'll type WeatherStatistics.exe. After loading the four data files, the program prompts me to enter a start date formatted with underscores. Let's see what the weather was like on New Year's Eve in 2013. That's 2013_12_31. Then, it prompts me for time in a 24-hour format separated by colons. I'll choose three o'clock in the afternoon, which corresponds to 15:00:00. Now it prompts me for an end date. So, I'll make it the next day, 2014 _01_01 at 7:30 in the morning. So, 07:30:00. According to the program, the pressure increased by around 0.43 inches of mercury per day between those start and end times, which means it was probably sunny. So, hopefully, people remembered to pack their sunscreen.

Contents