Write a C++ program that estimates the average weather temperatures for the State of California for four (4) days in the month of May 2021.  The temperature data (°C) provided in each day for each time interval (6:00 AM to 12:00 PM) is shown in this table, and Figure 1 displays the example output that the software will produce: Day/Hour-Hour 6-7 7-8 8-9 9-10 10-11 11-12 Day 1 17.2 18.1 21.5 24.3 25.5 26.0 Day 2 15.3 17.4 19.5 20.2 22.1 23.5 Day 3 16.1 18.5 19.0 19.8 21.2 22.4 Day 4 18.0 18.9 19.4 22.6 23.8 24.7 The program shall allow user to enter the data for six (6) time intervals. The program shall then display the hourly weather temperatures in tabular format (column: time interval, row: day) with the average temperatures on the interval 6:00 AM to 12:00 PM in each respective day. Following is the description of the program: a)     The program uses a 1-dimensional array to store the day and a 2-dimensional array to store the hourly temperatures for the six (6) intervals of each day of the month May 2021 using pointer notations. b)     One void function named enterData()  is defined to enter the information for 6 intervals in four (4) iterations. c)     One function named calcAvgTemps() is defined to calculate and returns a double value of  the average temperature for each day. The function takes two (2) arguments. The function shall be called in a loop in your main() function. d)     One function named displayData() is defined to display all values stored in the 2-dimensional array after (c) has been calculated. This function shall be called through main(). You are given the partial codes below. Complete the code to achieve the output in Figure 1. #include  #include  #include  using namespace std; const int ROW = 4; const int COL = 7; //prototype void enterData(); double calcAvgTemp(); void displayData(); string day[] = {"Day 1", "Day 2", "Day 3", "Day 4"}; int main() {     double hourly_temps[ROW][COL];     double avg, sum;     //function call to enter data     for (int k = 0; k < ROW; k++)     {         sum = 0.0;         //function call here to calculate average     }     cout << endl;     //function call to display     return 0; } void enterData() // {     cout << setw(38) << "Hour-Hour" << setw(6) << "6-7" << setw(6) << "7-8"          << setw(6) << "8-9" << setw(7) << "9-10" << setw(8) << "10-11" << setw(8) << "11-12" << endl          << endl;     //loop through user entry } void displayData() // {     cout << "Hour-Hour" << setw(6) << "6-7" << setw(8) << "7-8" << setw(8) << "8-9" << setw(9) << "9-10" << setw(9) << "10-11" << setw(8) << "11-12" << setw(6) << "Avg" << endl;     //loop through display data } double calcAvgTemp() // {     double average, sum = 0.0;     //loop through accumulate total     //calculate average

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
icon
Concept explainers
Question

Write a C++ program that estimates the average weather temperatures for the State of California for four (4) days in the month of May 2021. 

The temperature data (°C) provided in each day for each time interval (6:00 AM to 12:00 PM) is shown in this table, and Figure 1 displays the example output that the software will produce:

Day/Hour-Hour

6-7

7-8

8-9

9-10

10-11

11-12

Day 1

17.2

18.1

21.5

24.3

25.5

26.0

Day 2

15.3

17.4

19.5

20.2

22.1

23.5

Day 3

16.1

18.5

19.0

19.8

21.2

22.4

Day 4

18.0

18.9

19.4

22.6

23.8

24.7

The program shall allow user to enter the data for six (6) time intervals. The program shall then display the hourly weather temperatures in tabular format (column: time interval, row: day) with the average temperatures on the interval 6:00 AM to 12:00 PM in each respective day. Following is the description of the program:

a)     The program uses a 1-dimensional array to store the day and a 2-dimensional array to store the hourly temperatures for the six (6) intervals of each day of the month May 2021 using pointer notations.

b)     One void function named enterData()  is defined to enter the information for 6 intervals in four (4) iterations.

c)     One function named calcAvgTemps() is defined to calculate and returns a double value of  the average temperature for each day. The function takes two (2) arguments. The function shall be called in a loop in your main() function.

d)     One function named displayData() is defined to display all values stored in the 2-dimensional array after (c) has been calculated. This function shall be called through main().

You are given the partial codes below. Complete the code to achieve the output in Figure 1.

#include <iostream>

#include <iomanip>

#include <string>

using namespace std;

const int ROW = 4;

const int COL = 7;

//prototype

void enterData();

double calcAvgTemp();

void displayData();

string day[] = {"Day 1", "Day 2", "Day 3", "Day 4"};

int main()

{

    double hourly_temps[ROW][COL];

    double avg, sum;

    //function call to enter data

    for (int k = 0; k < ROW; k++)

    {

        sum = 0.0;

        //function call here to calculate average
    }

    cout << endl;

    //function call to display

    return 0;
}

void enterData() //

{

    cout << setw(38) << "Hour-Hour" << setw(6) << "6-7" << setw(6) << "7-8"

         << setw(6) << "8-9" << setw(7) << "9-10" << setw(8) << "10-11" << setw(8) << "11-12" << endl
         << endl;

    //loop through user entry
}

void displayData() //

{

    cout << "Hour-Hour" << setw(6) << "6-7" << setw(8) << "7-8" << setw(8) << "8-9" << setw(9) << "9-10" << setw(9) << "10-11" << setw(8) << "11-12" << setw(6) << "Avg" << endl;

    //loop through display data
}

double calcAvgTemp() //

{

    double average, sum = 0.0;

    //loop through accumulate total

    //calculate average

    return average;
}
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Operators
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education