Question

Problem: The average annual water level of Lake Michigan since 1860 has been provided in the...

Problem: The average annual water level of Lake Michigan since 1860 has been provided in the file “LMWL.txt”. The file is formatted so that the first column is the year and the second column is the average water level in feet above sea level for that year. Write a program to obtain the following information:

  1. What year had the lowest average water level, and what was the level (in feet)?
  2. What has the average water level of Lake Michigan been, since 1860 (in feet)?
  3. How many years have had a water level of less than 577 ft, and which years were they?

ALL printf statements MUST be in main() unless otherwise noted.

NOTE: You can verify your results with EXCEL.

Follow these detailed instructions:

  1. First, read this document in its entirety.
  2. Include the usual (detailed) comment block including program name, author, date, and description (at a minimum), followed by your preprocessor directives.
  3. An outline (Skeleton-code) of the source code is shown below, and also posted to Blackboard as WaterLevel.c and you are REQUIRED to follow this outline. You may write other supporting functions but you MUST have at least the 4 functions prototyped. Insert appropriate printf statements where needed to get the desired output. The outline has four sections where you are to enter in your code and complete the program.
    1. Part 1: You are required to write a function called ReadFile to read the data from “LMWL.txt” into 2 arrays. Remember to check if the file exists and not read past the EOF. The error message if file does not exist can be in the function. The function will return the number of data points in the file. NOTE: Remember, the data is in pairs with the first number being a year and the second being a record of average water level in feet. Print out the data in two columns from main().
  1. Part 2: You are required to write a function called LowPoint which accepts the array of water levels, and a parameter named size which indicates the size of the array. This function returns an integer indicating the array index number that corresponds to the lowest water level. Print out the year and lowest water level from main().
  1. Part 3: You are required to write a function called AverageLevel which accepts the array of water levels and a parameter named size which indicates the size of the array. This function returns the average water level since 1860. Print out the average water level since 1860 from main().
  1. Part 4: You are required to write a function called LowYears which accepts the array of water levels, the array of years, and a parameter named size which indicates the size of the array. This function returns the number of years with a water level less than 577 ft since 1860. Print out each year and its water level from the function, and the total number of years from main().

*******MUST USE THIS OUTLINE******

OUTLINE OF THE SOURCE CODE:

#include <stdio.h>

#define MAX_SIZE 200       //can go back 200 years if necessary

int ReadFile (int data1[], double data2[]);

int LowPoint (double data[], int size);

double AverageLevel (double data[], int size);

int LowYears (double data[], int year[], int size);

int main (void) {

     int Year[MAX_SIZE];

     double WaterLevel[MAX_SIZE],Average;

     int FileLength, IndexLow, NumberLow;

     //Place any additional variable declarations required below this line

     //Describe code

     //Read file using function

    FileLength = ReadFile(Year,WaterLevel);

    //Print out data in two columns with first being year and second

    //being water level in feet

    IndexLow = LowPoint(WaterLevel,FileLength);

    //Print out the year and lowest water level

    Average = AverageLevel(WaterLevel, FileLength);

     //Print out the average water level since 1860

     NumberLow = LowYears(WaterLevel,Year,FileLength);

     //Print out the total number of years with a water level less than 577 feet

     return 0;

}

// Code for part 1 goes here, include ALL error checks.

// Code for part 2 goes here

// Code for part 3 goes here

// Code for part 4 goes here

*****LMWL file*****

1860   581.8082906
1861   581.7973542
1862   581.7454077
1863   581.29812
1864   580.6941718
1865   580.3978027
1866   580.0713591
1867   580.5006023
1868   580.016952
1869   580.1347886
1870   581.0367463
1871   580.9610137
1872   579.8288503
1873   580.4423674
1874   580.8442702
1875   580.6047689
1876   581.6456154
1877   581.3555347
1878   581.0968949
1879   580.227199
1880   580.3945219
1881   580.7759195
1882   581.1190406
1883   581.3965452
1884   581.6056987
1885   581.761265
1886   581.9860025
1887   581.3290143
1888   580.6862433
1889   580.1815406
1890   580.0131242
1891   579.4452656
1892   579.2782161
1893   579.4633103
1894   579.6626213
1895   578.8063221
1896   578.4962827
1897   579.099137
1898   579.2533365
1898   579.2634523
1900   579.2738418
1901   579.5333014
1902   579.1685813
1903   579.3137584
1904   579.8756272
1905   579.9086843
1906   579.9327437
1907   580.001368
1908   579.9445248
1909   579.3924986
1910   579.0764444
1911   578.5290911
1912   578.9922361
1913   579.6268053
1914   579.1657729
1915   578.5878726
1916   579.3030957
1917   580.0462059
1918   580.3368339
1919   579.8720481
1920   579.4783473
1921   579.0299658
1922   578.8877962
1923   578.294511
1924   578.040246
1925   577.1626213
1926   577.0505258
1927   577.9144802
1928   578.882328
1929   580.366908
1930   579.5631023
1931   577.816055
1932   577.2337059
1933   576.9931111
1934   576.6622932
1935   577.0696639
1936   577.2282381
1937   577.1735573
1938   577.8898739
1939   578.3109152
1940   577.8926082
1941   577.8269914
1942   578.5241698
1943   579.4838155
1944   579.3853903
1945   579.2979011
1946   579.4017945
1947   579.2869651
1948   579.1694015
1949   578.1195327
1950   578.2835747
1951   579.8419737
1952   580.9875337
1953   580.4899395
1954   580.1481856
1955   579.7982292
1956   578.871392
1957   578.2917768
1958   577.6492791
1959   577.4469605
1960   578.9944235
1961   578.6636055
1962   578.1578093
1963   577.1735573
1964   576.3861557
1965   577.1516849
1966   577.9554907
1967   578.4148083
1968   578.8932643
1969   579.7107401
1970   579.6533254
1971   580.0688985
1972   580.3423017
1973   581.1132991
1974   581.0148739
1975   580.6211731
1976   580.3778444
1977   579.0846465
1978   579.3662519
1979   580.0333562
1980   580.0634303
1981   579.7189422
1982   579.3908582
1983   580.1618555
1984   580.3641741
1985   581.1242355
1986   581.668308
1987   580.6102371
1988   579.278763
1989   578.7428923
1990   578.5761164
1991   578.9670832
1992   578.9998916
1993   579.7107401
1994   579.6533254
1995   579.1584654
1996   579.5740386
1997   580.6567158
1998   579.7790911
1999   578.2015537
2000   577.3567374
2001   577.2665143
2002   577.816055
2003   577.0723982
2004   577.7914487
2005   577.723098
2006   577.4797689
2007   577.241908
2008   577.4442266
2009   578.2753726
2010   577.7914487
2011   577.5479011
2012   577.1515757
2013   577.0997384
2014   578.4175425
2015   579.3635179

0 0
Add a comment Improve this question Transcribed image text
Know the answer?
Add Answer to:
Problem: The average annual water level of Lake Michigan since 1860 has been provided in the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • ***HELP FINISH CODE*** Problem: The total snowfall (in inches) in the state of Michigan over the...

    ***HELP FINISH CODE*** Problem: The total snowfall (in inches) in the state of Michigan over the last 20 years has been provided in the file “snowfall.txt”. The file is formatted so that the first column is the year and the second column is the snowfall in inches for that year. Write a program to obtain the following information: What year was the greatest amount of snowfall and how much fell that year (in inches)? What year was the 2nd highest...

  • #include <stdio.h> // Define other functions here to process the filled array: average, max, min, sort,...

    #include <stdio.h> // Define other functions here to process the filled array: average, max, min, sort, search // Define computeAvg here // Define findMax here // Define findMin here // Define selectionSort here ( copy from zyBooks 11.6.1 ) // Define binarySearch here int main(void) { // Declare variables FILE* inFile = NULL; // File pointer int singleNum; // Data value read from file int valuesRead; // Number of data values read in by fscanf int counter=0; // Counter of...

  • The code should be written in C++. I included the Class used for this function. Also,...

    The code should be written in C++. I included the Class used for this function. Also, please fix the main function if necessary. Description: This function de-allocates all memory allocated to INV. This will be the last function to be called (automatically by the compiler) //before the program is exited. This function also erased all data in the data file. There are other functions that add, process and alter the file; the file printed after those functions will have new...

  • Hi!, having trouble with this one, In this class we use visual studio, C++ language --------------------------------------------------------------...

    Hi!, having trouble with this one, In this class we use visual studio, C++ language -------------------------------------------------------------- Exercise #10 Pointers - Complete the missing 5 portions of part1 (2 additions) and part2 (3 additions) Part 1 - Using Pointers int largeArray (const int [], int); int largePointer(const int * , int); void fillArray (int * , int howMany); void printArray (const char *,ostream &, const int *, int howMany); const int low = 50; const int high = 90; void main()...

  • INPUT FILE INTO ARRAY. CHECKING FOR COMMAS AND SUCH. HOW TO DO? PLEASE READ CAREFULLY. MAX_SIZE...

    INPUT FILE INTO ARRAY. CHECKING FOR COMMAS AND SUCH. HOW TO DO? PLEASE READ CAREFULLY. MAX_SIZE is size of array When iterating over the candidates’ list, do not iterate over the entire array, but just over the records where data is filled in void readFile(Candidate candidates[]) – reads the elections.txt file, fills the candidates[] array. Hint: use substr() and find() functions. Set Score to 0. void List(Candidate candidates[]) – prints the array of Candidate structs. One candidate per one line,...

  • Lanuage C++ (Beginner level) Please...I need help with this assignment If I still have question, can...

    Lanuage C++ (Beginner level) Please...I need help with this assignment If I still have question, can i contact you? -------------------------- Program 1 - WRITE ALL THE CODE in ONE FILE...   MyArrayPtrArith1.cpp Step 1 - Define the class Write a class, myArrayClass, that creates an integer array. * Add an 'arraySize' variable, initialize to zero ( default constructor function ) * Create int * ptrArray ( default constructor set to NULL ) * Add a default constructor ( see above for...

  • write a C++program to analyze a small subset of the data that has been collected. See...

    write a C++program to analyze a small subset of the data that has been collected. See file universities.txt .Use precisely seven parallel arrays: one for name of university, one for state, one for city, one for yearly tuition, one for enrollment, one for average freshman retention, and one for the percent of students who graduate with in six years. Note that the percentage of student accepted is not stored.An output file is opened in main() and remains open until the...

  • 18.1 Lab Lesson 11 (Part 1 of 1) Part of lab lesson 11 There in one...

    18.1 Lab Lesson 11 (Part 1 of 1) Part of lab lesson 11 There in one part to lab lesson 11. The entire lab will be worth 100 points. Lab lesson 11 part 1 is worth 100 points For part 1 you will have 80 points if you enter the program and successfully run the program tests. An additional 20 points will be based on the style and formatting of your C++ code. Style points The 20 points for coding...

  • This should be in Java Create a simple hash table You should use an array for...

    This should be in Java Create a simple hash table You should use an array for the hash table, start with a size of 5 and when you get to 80% capacity double the size of your array each time. You should create a class to hold the data, which will be a key, value pair You should use an integer for you key, and a String for your value. For this lab assignment, we will keep it simple Use...

  • In C++ Do not use a compiler like CodeBlocks or online. Trace the code by hand....

    In C++ Do not use a compiler like CodeBlocks or online. Trace the code by hand. Do not write "#include" and do not write whole "main()" function. Write only the minimal necessary code to accomplish the required task.                                                                                                           Save your answer file with the name: "FinalA.txt" 1) (2 pts) Given this loop                                                                                              int cnt = 1;     do {     cnt += 3;     } while (cnt < 25);     cout << cnt; It runs ________ times    ...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT