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: Function getData: This function reads and stores data in the two- dimensional array. а. Function averageHigh: This function calculates and returns the aver- age high temperature for the year. b. Function averageLow: This function calculates and returns the average low temperature for the year. c. Function indexHighTemp: This function returns the index of the highest high temperature in the array. d. Function indexLowTemp: This function returns the index of the lowest low temperature in the array. е.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 23PE
icon
Related questions
Question

Can this code be inplimented in C++ and look exactly like the output file. All of the output should be displayed in the outfile called weatherout.txt and all of the input temperatures should be read and used from the input file called weather.txt. The temperatures should be displayed in two colums like shown in the sample output. 

I have included the main function and skeleton of the solution that can be used to compelete the code and guide in the right direction.

 

const int NO_OF_MONTHS = 12;

 

void getData(int twoDim[][2], int rows);

int averageHigh(int twoDim[][2], int rows);

int averageLow(int twoDim[][2], int rows);

int indexHighTemp(int twoDim[][2], int rows);

int indexLowTemp(int twoDim[][2], int rows);

void display(int twoDim[][2], int);

 

ifstream inFile("weather.txt");

ofstream outFile("Wearther.out");

 

int main()

{

    int hiLowArray[NO_OF_MONTHS][2];

 

    int indexHigh;

    int indexLow;

 

    getData(hiLowArray, NO_OF_MONTHS);

 

     display(hiLowArray,NO_OF_MONTHS);

 

    cout << "\nAverage high temperature: "

         << averageHigh(hiLowArray, NO_OF_MONTHS) << endl;

     outFile << "\nAverage high temperature: "

         << averageHigh(hiLowArray, NO_OF_MONTHS) << endl;

 

    cout << "\nAverage low temperature: "

         << averageLow(hiLowArray, NO_OF_MONTHS) << endl;

     outFile << "\nAverage low temperature: "

         << averageLow(hiLowArray, NO_OF_MONTHS) << endl;

 

    indexHigh = indexHighTemp(hiLowArray, NO_OF_MONTHS);

    cout << "\nHighest temperature: " << hiLowArray[indexHigh][0] << endl;

     outFile << "\nHighest temperature: " << hiLowArray[indexHigh][0] << endl;

 

    indexLow = indexLowTemp(hiLowArray, NO_OF_MONTHS);

    cout << "\nLowest temperature: " << hiLowArray[indexLow][1] << endl;

     outFile << "\nLowest temperature: " << hiLowArray[indexLow][1] << endl;

 

    return 0;

}

Sample Output of the Program:
The following is the Brownsville's yearlong high and low temperatures
Month
High
Low
January
February
70
53
74
56
March
78
60
April
Мay
84
68
88
73
June
91
76
July
August
September
93
76
93
77
90
74
October
85
67
November
78
60
December
71
53
Average high temperature: 82
Average low temperature: 66
Highest temperature: 93
Lowest temperature: 53
Transcribed Image Text:Sample Output of the Program: The following is the Brownsville's yearlong high and low temperatures Month High Low January February 70 53 74 56 March 78 60 April Мay 84 68 88 73 June 91 76 July August September 93 76 93 77 90 74 October 85 67 November 78 60 December 71 53 Average high temperature: 82 Average low temperature: 66 Highest temperature: 93 Lowest temperature: 53
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:
9.
Function getData: This function reads and stores data in the two-
dimensional array.
а.
Function averageHigh: This function calculates and returns the aver-
age high temperature for the year.
Function averageLow: This function calculates and returns the average
low temperature for the year.
b.
с.
Function indexHighTemp: This function returns the index of the
highest high temperature in the array.
d.
Function indexLowTemp: This function returns the index of the lowest
low temperature in the array.
(These functions must all have the appropriate parameters.)
е.
Transcribed Image Text: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: 9. Function getData: This function reads and stores data in the two- dimensional array. а. Function averageHigh: This function calculates and returns the aver- age high temperature for the year. Function averageLow: This function calculates and returns the average low temperature for the year. b. с. Function indexHighTemp: This function returns the index of the highest high temperature in the array. d. Function indexLowTemp: This function returns the index of the lowest low temperature in the array. (These functions must all have the appropriate parameters.) е.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 7 images

Blurred answer
Knowledge Booster
Datatypes
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr