Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For this exercise, you will be simulating a weather station responsible for recording hourly temperatures and reporting on certain characteristics (e.g., average temperature) from your

For this exercise, you will be simulating a weather station responsible for recording hourly

temperatures and reporting on certain characteristics (e.g., average temperature) from your recordings.

You will also be expanding on your experience in creating functions and passing them more complex

parameters (i.e., complete array arguments).

Specifications:

DDI&T a C++ program to input, store, and process hourly temperatures for each hour of the day

(i.e., 24 temperatures). Your program should be divided logically into the following parts:

1. In function main() declare an array:

array HourlyTemperatures;

(where NUM_TEMPERATURES should be declared as a constant with the value, 24), that

will be used to hold one temperature for each hour of the day. Declare other variables and

constants as you feel are necessary.

2. Pass the HourlyTemperatures array to a function,

void GetTemperatures(array & Temperatures);

This function must interactively prompt for and input temperatures for each of the 24 hours

in a day (0 through 23). For each temperature that is input, verify that its value lies in the

range of minus 50 degrees and plus 130 degrees (i.e., validate your input values). If any

value is outside the acceptable range, ask the user to re-enter the value until it is within this

range before going on to the next temperature (HINT: use a nested loop (e.g., do-while) that

exits only when a value in the specified range has been entered). Store each validated

temperature in its corresponding element of the 24-element integer array passed as a

parameter to the function.

3. Next pass the filled array to a function,

double ComputeAverageTemp(array & Temperatures);

This function computes the average temperature of all the temperatures in the array and

returns this average to the calling function.

4. Finally, pass your array and the computed average temperature to another function,

void DisplayTemperatures(array & Temperatures,

double AverageTemp);

which displays the values of your temperature array in a columnar format followed by the

values for the high temperature, low temperature, and average temperature for the day.

NOTE: If you want to create separate function(s) to find and return the high and low

temperature values, then feel free to do so!

The resulting output should look like this:

Hour Temperature

00:00 42

01:00 42

. . . . . . . . // Your program output must include all of these too!

22:00 46

23:00 48

High Temperature: 68

Low Temperature: 42

Average Temperature: 57.4

5. Since you have created functions to perform each of the functional steps of your solution,

your main() function should be quite simple. The pseudo code for main() might look

something like this:

int main()

{

// declare local constant(s), variable(s), and array(s).

do

{

// call GetTemperatures(HourlyTemperatures);

// call ComputeAverageTemp(HourlyTemperatures);

// call DisplayTemperatures(HourlyTemperatures, AverageTemperature);

} while // user wants to process more days of temperatures

return 0;

}

6. Test your program with at least two (2) different sets of temperatures. Make sure you

enter values to adequately test your temperature-validation code (e.g., temperatures below

50 and above +130 degrees).

Deliverable(s):

Turn in the properly documented source listing of your program and complete outputs from

at least TWO (2) test runs. Additionally, turn in screen captures of some of your interactive inputs

demonstrating that your program properly detects invalid inputs and prompts the user to re-enter the

temperature(s). Starting with this exercise you must document your solution in accordance with the

examples shown at the back of this syllabus and provided on the Portal.

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

Step: 3

blur-text-image

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

Oracle Database Administration The Essential Reference

Authors: Brian Laskey, David Kreines

1st Edition

1565925165, 978-1565925168

More Books

Students also viewed these Databases questions