Question
C++ Write a program that uses a struct and an array of structs to store the 12 months, and the high temperature and low temperature
C++
Write a program that uses a struct and an array of structs to store the 12 months, and the high temperature and low temperature for each month. The program should read the Months names, and the temperatures from a given input file called temps.txt. The program should output the highest and lowest temperatures for the year, and the months that correspond to those temperatures. Your program MUST use the following functions: 1. Create a struct called Temperature with data members to store month, high temperature and low temperature. 2. Function loadData: The function reads and stores data in the array of struct from a text file (temps.txt). void loadData(ifstream &infile, Temperature [], int &size); 3. Function averageHigh: This function calculates and returns that record that has the high temperature. From that, you can print the high temperature and the corresponding month in main. Temperaure averageHigh(Temperature [], int size); 4. Function averageLow: This function calculates and returns that record that has the low temperature. From that, you can print the low temperature and the corresponding month in main. Temperaure averageLow(Temperature [], int size); Design Considerations Please use a while loop to read all lines of text from input file. Keep the input file in the same directory as your project.
the text file is
January 47 36 February 51 37 March 57 39 April 62 43 May 69 48 June 73 52 July 81 56 August 81 57 September 75 52 October 64 46 November 52 41 December 45 35
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