Hey everyone. I've been working on a homework assignment to simulate a weather station responsible for recording hourly temps and reporting an average temp. I'm supposed to be passing an array to different functions to first get the temps and input them into the array. Then, compute the average temp from the array. Finally, display the array in a table format. I've got the code all typed up, but I keep getting an error that says... "function does not take 0 arguments" for each of my call to functions in the main..
So, here's the code I wrote that's not playing nicely. Also, attached the files for viewing too.
Header File
#ifndef Lab4_h
#define Lab4_h
void GetTemperatures (int Temperatures[], int NumTemperatures);
double ComputeAverageTemp (int Temperatures[], int NumTemperatures);
void DisplayTemperatures (int Temperatures[], int NumTemperatures, double AverageTemp);
#endif
CPP File
#include <iostream>
using std::cin;
using std::cout;
using std::endl;
#include "Lab4.h"
int main ()
{
const int NumTemperatures = 24;
int HourlyTemperatures[NumTemperatures] = {0};
GetTemperatures ();
ComputeAverageTemp ();
DisplayTemperatures ();
return 0;
}
void GetTemperatures (int Temperatures[], int NumTemperatures)
{
int Count = 0;
int CurrentTemp = 0;
while (Count < 24)
{
cout << "Input hourly temp: ";
cin >> CurrentTemp;
Temperatures[++Count] = CurrentTemp;
}
}
double ComputeAverageTemp (int Temperatures[], int NumTemperatures)
{
double AverageTemp = 0.0;
int Count = 0;
int Sum = 0;
for (Count = 0; Count < 24; Count++)
{
Sum = Sum + Temperatures[Count];
}
AverageTemp = Sum / NumTemperatures;
return AverageTemp;
}
void DisplayTemperatures (int Temperatures[], int NumTemperatures, double AverageTemp)
{
int Count = 0;
cout << "*******************************\n";
cout << "Hour\t\tTemperature\n";
while (Count < 24)
{
cout << "0" << ++Count << ":00\t\t" << Temperatures[Count] << endl;
}
cout << "High Temp: \t\t\n";
cout << "Low Temp: \t\t\n";
cout << "Average Temp: \t\t" << AverageTemp << endl;
cout << "*******************************\n";
}