I am taking this C+ +programming class online and is really struggling learning the concept. Would someone be so kind to help me out with this problem:
A weather station will take 3 temperature readings each day for 7 days (Celsius) before reporting the aggregate data.
I would like to create a program that will read in the 21 Celsius temperature values and store the values in a two-dimensional array.
I would also like to create separate functions for the following tasks:
a. Calculate the average temperature
b. Calculate the high temperature
c. Calculate the low temperature
From the main function, I would like to call the functions created to retrieve the average, high, and low temperatures and display the results in both Fahrenheit and Celsius.
I would like to use the following formula to convert from Celsius to Fahrenheit:
Fahrenheit = Celsius * (212 – 32) / 100 + 32
This is what I came up with:
This won't compile. Is there someone that might have some
time to help me out, I really appreciate it.
#include <iostream>
using std::cin;
using std::cout;
using std::endl;
const int DAYS = 7;
const int READINGS = 3;
// function prototypes
double calculateAvg(double temps[][READINGS]);
double calculateHigh(double temps[][READINGS]);
double calculateLow(double temps[][READINGS]);
double c2f(double degreesC);
int main()
{
double cTemps[DAYS][READINGS];
for (int day = 0; day < 7; ++day)
{
for (int reading = 0; reading < 3; ++reading)
{
// you could make this more meaningful
// by including the day and reading in
// prompt.
cout << “Enter Celsius temperature: “;
cin >> cTemps[day][reading];
}
}
cout << endl;
cout << “In degrees C:” << endl;
cout << “Avg temp is: “ << calculateAvg(cTemps) << endl;
cout << “Max temp is: “ << calculateHigh(cTemps) << endl;
cout << “Min temp is: “ << calculateMin(cTemps) << endl;
cout << endl;
cout << “In degrees F:” << endl;
cout << “Avg temp is: “ << c2f(calculateAvg(cTemps)) << endl;
cout << “Max temp is: “ << c2f(calculateHigh(cTemps)) << endl;
cout << “Min temp is: “ << c2f(calculateMin(cTemps)) << endl;
return 0; }
}
// function definitions omitted