Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem: Is the Earth warming up? Are the temperatures we have been experiencing recently normal fluctuations or evidence of a warming trend? Write a C++

Problem: Is the Earth warming up? Are the temperatures we have been experiencing recently normal fluctuations or evidence of a warming trend? Write a C++ program to analyze temperature data from March, April and May of 2015 for Ohio. Create a project CS2010_Firstname_Program 6-7. Finish the first 5 steps and upload your program to canvas through the program 6 submission link by 11/11; continue working, finish steps 6-8, and upload the complete program to canvas through the program 7 submission link by 11/21.

Input: The temperature (in Celsius) for each day of March, April and May (92 temperatures) is stored in the file pgm6.txt. Copy this file from the Canvas class web site to your project folder. Be sure that the txt file is in the same directory as your cpp file. Your project should read in each temperature and store it in the next available element of an array of type double. All of the temperatures must be stored in the same array. Then using the data values stored in the array, perform the steps described below.

Processing: Your main function should do the following:

1. Declare the array to hold the temperatures and any other variables needed. That is to say, you are not allowed to declare a global array outside the main function. You need to know how to pass arrays from main function to other functions. (See the handout Passing array to functions).

2. Call a function to read the daily temperatures from the file pgm6.txt, storing each temperature in an element in the array. Open and close the data file in this function. All further processing must be done using the data values stored in the array. Temperatures in the file look like this:

0

-5.55556

-1.66667

6.11111

3. Call a function to display the temperatures for the month of March. Include a heading with your name and two columns one showing the day of the month and one showing the temperature for that day (see sample below).

Temperatures for March

Your Name

Day Temperature

of month (Celsius)

-----------------------

1 0

2 -6

3 -2

4 6

4. Call a function to convert all of the temperatures in the array from Celsius to Fahrenheit (F = 9.0/5.0 * C + 32), replacing the original Celsius temperature with the Fahrenheit value for each element. Note: You do not need to create a new array for this function, just change the values in the original array.

5. Call a function to display the temperatures for the month of April to show that the temperatures have been converted correctly. Include a heading, your name and the two columns see sample below. (See if you can use the function from Step 3 again.)

Temperatures for April

Your Name

Day Temperature

of month (Fahrenheit)

----------------------------

1 61

2 73

3 57

4 56

6. Call a function to find and return the average temperature in Fahrenheit for the three-month period. The main function should display this result with an appropriate description.

7. Call a function to find and display the number of days that had a temperature above the average for this period. Clearly label your output.

8. Call a function to find the highest temperature for each month and display each value with an appropriate label. Hint: Start by finding the highest temperature for March. Then think about how you could generalize this to do the same for the other two months.

Program Design: A structure chart for your program is shown below. Work on one function at a time. For each function decide what its parameter(s) should be: what data, if any, needs to be passed to the function; what results, if any, will the function return or pass back. Then write the function prototype, function call and function definition. Make sure these match in the required ways. Determine where each of these should be located in your program and type them in, including documentation. Be sure to test and debug each function before going on to the next one.

TEMPERATURES

31.1111 27.7778 31.1111 23.3333 23.8889 26.6667 28.8889 26.6667 25 23.8889 27.7778 25.5556 25 25.5556 30 31.1111 33.8889 34.4444 28.8889 28.8889 25.5556 30 32.7778 31.1111 29.4444 30 31.1111 31.6667 31.1111 30.5556 33.3333 30 25 25.5556 26.6667 27.2222 29.4444 29.4444 28.8889 28.3333 30 31.6667 32.2222 28.8889 25.5556 23.3333 26.1111 26.6667 22.7778 27.7778 31.6667 33.3333 28.8889 26.6667 27.2222 29.4444 27.7778 24.4444 22.7778 26.1111 28.3333 30.5556 25 28.8889 31.1111 30.5556 29.4444 28.3333 29.4444 30 31.6667 29.4444 27.7778 26.6667 25.5556 25.5556 27.7778 28.8889 30.5556 32.7778 32.2222 25 28.8889 31.6667 30.5556 30.5556 32.2222 32.7778 27.2222 30.5556 33.8889 27.7778

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_2

Step: 3

blur-text-image_3

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

Essential SQLAlchemy Mapping Python To Databases

Authors: Myers, Jason Myers

2nd Edition

1491916567, 9781491916568

More Books

Students also viewed these Databases questions