Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems For Advanced Applications 9th International Conference Dasfaa 2004 Jeju Island Korea March 2004 Proceedings Lncs 2973

Authors: YoonJoon Lee ,Jianzhong Li ,Kyu-Young Whang

2004th Edition

3540210474, 978-3540210474

More Books

Students also viewed these Databases questions

Question

=+Is the guilt appropriate for the audience?

Answered: 1 week ago