Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using Linux Working with two dimensional array. Write a C++ program which gets the temperatures for morning and afternoon for 7 days of a week.

Using Linux Working with two dimensional array. Write a C++ program which gets the temperatures for morning and afternoon for 7 days of a week. This means that you have to get 14 temperatures as input. Your program should have four different functions a required below.

Requirements:

Declare a two dimensional array called Temp with data type double.

The two sizes you use for the two dimensions of array Temp should be declared as global Constants.

Write a function called fillup_array which is responsible to get the input for array Temp.

Write a function called find_average which is responsible to find the average temperature for the entire week. This function gets the array Temp as input. Use call by reference to access the average temperature inside the main function (Your function should not return back any value) Don't forget the two digits precision when you calculate the average. Use the cout statement inside the main function to print the average temperature for the entire week.

Write a function called find_daily_mmm. This function is responsible to find the maximum, minimum, and mean temperature for each day in a week. This function has four arguments including: array Temp, max, min, and mean. This function does not return back any value. Use call by reference to save the values for max, mean, and min inside the related function arguments. You should call function find_daily_mmm inside the main function for each day of week. Don't forget the two digits precision when you calculate the mean.

Write a function called show_warmer. This function takes the array Temp as one of its input parameters. It also gets another input called cutoff, which is a base temperature using for comparison. This function compares all the temperatures in a week with the cutoff and prints each day of a week which is warmer than cutoff. Your function then needs to print the day and temperature.

Considering the cutoff 10, one example of the printed message by this function is : At day 6, morning, the temperature was 11 which is warmer than 10

When you check your array to find the temperatures that are warmer than the cutoff you need to figure out a way to know if the temperature is for morning or afternoon. (you need this information when you print the message)

A sample run of your program should look like:

Please enter the morning and afternoon temperatures for 7 days of a week: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 The average temperature over all the days is: 7.5 The maximum, minimum, and mean temperature for each day:

Day 1: max 2.00, min:1.00, mean:1.50 Day 2: max 4.00, min:3.00, mean:3.50 Day 3: max 6.00, min:5.00, mean:5.50 Day 4: max 8.00, min:7.00, mean:7.50 Day 5: max 10.00, min:9.00, mean:9.50 Day 6: max 12.00, min:11.00, mean:11.50 Day 7: max 14.00, min:13.00, mean:13.50

Enter the value for which to find the warmer temperature : 10 Days at which the temperature warmer than 10.00 were found: At day 6, morning, the temperature was 11.00 which is warmer than 10 At day 6, afternoon, the temperature was 12.00 which is warmer than 10 At day 7, morning, the temperature was 13.00 which is warmer than 10 At day 7, afternoon, the temperature was 14.00 which is warmer than 10

Compile your program using g++ -Wall program8.cpp -o output

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

More Books

Students also viewed these Databases questions