Course Answers

BUSINESS
COMPUTER SCIENCE
OTHER COURSES
My Profile

Solved: Write A C++ Program That Uses A Two Parallel Arrays To Store The Highest And Lowest Temperatures For Each Month Of One Year. You Should Also Have A Parallel Array To Store The Names Of The 12

By |

write a C++ program that uses a two parallel arrays to store the highest and lowest temperatures for each month of one year. You should also have a parallel array to store the names of the 12 months. The program should read the months’ names, and the temperatures from a given input file called temps.txt. The main 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: • Function loadData: The function reads and stores data in the parallel array and 2D array from a text file (temps.txt). int loadData( ifstream &infile, string months[], int lows[], int highs[], int &rows ) (Note that the last parameter returns the number of rows of data read from the file.) • Function findLow: This function finds and returns the low temperature and the corresponding month of the year. int findLow( int lows[], int rows, int &lowtemp, int &month ) • Function findHigh: This function finds and returns the high temperature and the corresponding month of the year. int findHigh( int highs[], int rows, int &hightemp, int &month ) Additional Requirements and Design Considerations: 1. The main program should display a brief description of the program. 2. The main program should report the number of months of data read from the file. 3. The main program should not call the High and Low functions if the number of rows is less than 1. 4. Do not use any global variables. (All variables must be declared inside functions.) 5. You must use all the given function prototypes and not change them. You can add more functions if you like. 6. The first thing each function should do is announce that it has been called, after which it should display no other output. 7. Use a while loop to read all lines of text from the input file. 8. loadData() should include code to prevent the arrays from being exceeded. 9. Each function should return 0 if no error occurred or a nonzero number if an error occurred. 10. The program should return an error if the file could not be opened. 11. Keep the input file in the same directory as your project.

This program finds the warmest and coldest months as listed in a data file. KloadData called) found 12 months of data Kaverag

temp.txt

January 47 36
February 51 37
March 57  39
April 62 43
May 69 48
June 73 52
July 81 56
August 83 57
September 81 52
October 64 46
November 52 41
December 45 35


This program finds the warmest and coldest months as listed in a data file. KloadData called) found 12 months of data KaverageHigh called> The highest average temperature was KaverageLow called The lowest average temperature was in in Process returned 0 (Ox0) Press any key to continue. execution time: 0.140 s

Answer Preview

Here is the completed code for this problem. Comments are included, go through it, learn how things work and let me know if you have any doubts or if you need anything to change. If you are satisfied

Get Answer Now


Buy (USD $9.00)

Get Answer Now

Answered
Buy @ USD $9.00
Related Questions

OTHER COURSES
OTHER COURSES
OTHER COURSES
OTHER COURSES
OTHER COURSES
OTHER COURSES
OTHER COURSES
OTHER COURSES
OTHER COURSES
OTHER COURSES