Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For this assignment, you will write a program where you read a set of high and low temperatures from a file and perform various statistics

image text in transcribed
For this assignment, you will write a program where you read a set of high and low temperatures from a file and perform various statistics on the data. You will create two filestream variables, one for reading and one for writing. You will create an array with 12 rows (one for each month of the year) and 2 columns where the first column will store that month's high temperature and the second column stores that month's low temperature. The data file will have 12 lines and each line will have the month's high temperature and low temperature with a blank space in between them and each line will be terminated with an end of line character. Your program will consist of the following: A named constant that holds 12, for the months of the year. A 12 by 2 array to hold the temperatures (the array type will be an integer) A set of functions void getData(int [] [2], ifstream&)-will read the data from the file and insert them into the array (that's passed as a parameter) double averageHigh(int[] [2])- will return the average of all the high temperatures for the year. double averageLow (int [] [2])-will return the average of all the low temperatures for the year int indexHighTemp (int [] [2])-will return the index (of the array) that contains the maximum high temperature int indexLowTemp (int [] [2])-will return the index (of the array) that contains the minimum low temperature string getMonth (int)-will return the month name for a given index so getMonth(0) will return the string "January" etc. As always create variables with meaningful names and comment all your variables, constants and all of your functions, also format your output numbers to two decimal places Contents of main What your main will do is prompt the user for an input file name and an output file name, if the input file name was not found, report the error and terminate the program. Otherwise call the function getData and pass the appropriate parameters and this function will basically return the array with all necessary data. Then you will call the other functions to get the average high and low, and the index with the high temperature etc. and output that to the output file

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

SQL For Data Science Data Cleaning Wrangling And Analytics With Relational Databases

Authors: Antonio Badia

1st Edition

3030575918, 978-3030575915

More Books

Students also viewed these Databases questions

Question

13. You always should try to make a good first impression.

Answered: 1 week ago