Hello, i have the following program to write. Write a program that uses a two di
ID: 3643183 • Letter: H
Question
Hello, i have the following program to write.Write a program that uses a two dimensional array to store the highest and lowest temperatures for each month of the year. The program should output the average high, average low, and the highest and lowest temperatures for the year. Your program must consist of the following functions: getData(reads and stores the data from the two dimesnional array, averageHigh(average high temp for year), averageLow(self explanatory), indexHighTemp(returns the index of the highest high temperature), indexLowTemp((returns index of the lowest low temp in array)
these functions must all have the appropriate parameters.
Also, i have my infile and out file as follows:
infile.open("H:\ch9ex10text.txt"); //open infile
outfile.open("H:\ch9ex10results.txt"); //where to send the results(flash Drive)
Thank you in advance
Explanation / Answer
#include #include #include using namespace std; //******function prototypes******** void getTemps(int xTemps[2][7]); void avgTemps(int xTempsX[2][7], double &high, double &low); int main () { //declare variables int temperatures = 0; const int DAYS = 7; const int TEMPS = 2; //declare array int temps[TEMPS][DAYS] = {0}; //asks for high and low temperatures getTemps(temps); //sets the two averages double avgHigh, avgLow; //calculates the average of the two arrays avgTemps(temps, avgHigh, avgLow); system("pause"); return 0; } //*****Functions***** void getTemps(int xTemps[2][7]) { for(int i = 0; i < 7; i++) { cout > xTemps[0][i]; cout > xTemps[1][i]; } } void avgTemps(int xTempsX[2][7], double &high, double &low) { high = 0; low = 0; for(int j = 0; j < 7; j++) { high += xTempsX[0][j]; low += xTempsX[1][j]; } high = high / 7; low = low / 7; coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.