Rainfall Statistics assistance

Hey dudes! I'm looking for some help with my code. I have almost everything working except my averageRainfall function. I don't know what I have wrong and I need a fresh set of eyes to look at it and give me a hand. Any help would be much appreciated, thanks!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136

#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <string>

using namespace std;

//Global V&C
const int SIZE= 12;

void welcome();
void getData (double [], int qty);
double totalRainfall(double [], int qty);
double averageRainfall(double [], int qty); 
void wettestMonth(double [], int &wM, double &highest);
void driestMonth(double [], int &dM, double &lowest);

int main()
{
	//V&C
	double rainfall[SIZE];
	double tRF = 0, aRF = 0, lowest, highest;
	int  wM = 0 , dM = 0;
	string month[12] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};


	welcome();

	//Input
	getData(rainfall, SIZE);

	tRF = totalRainfall(rainfall, SIZE);

//	aRF = averageRainfall(rainfall, SIZE);

	wettestMonth(rainfall, wM, highest);

	driestMonth(rainfall, dM, lowest);

	//Output
	cout<<fixed<<setprecision(2);
	cout<<endl<<"The Rain Report for Neversnows County"<<endl;
	cout<<"-------------------------------------"<<endl;
	cout<<"Total rainfall for the year: "<<tRF<<" inches"<<endl;
	cout<<"Average rainfall for the year: "<<aRF<<" inches"<<endl;
	cout<<"The least amount of rain fell in "<<month[dM]<<" with "<<lowest<<" inches"<<endl;
	cout<<"The most amount of rain fell in "<<month[wM]<<" with "<<highest<<" inches"<<endl;
	cout<<"-------------------------------------"<<endl;

	return 0;

}



void welcome ()
{
	cout << "Welcome to the Rainfall Statistics Program "<<endl;
	return;
}

void getData (double rainfall [], int SIZE)
{
	int count;

	cout<< "Please enter the amount of inches of rainfall for the year.\n(Please hit the Return key after each input)"<<endl;
	for (count = 0; count < SIZE; count++)
	{
		cin>> rainfall[count];

		//Validation
		if (rainfall[count] < 0)
		{
			cout << "Please only use positive numbers." << endl;
			cin>> rainfall[count];
		}

	}

}


double totalRainfall(double rainfall [], int SIZE)
{
	int count;
	double tRF = 0;

	for (count = 0; count < SIZE; count++)
	{
		tRF += rainfall[count];
	}
	return tRF;
}


double averageRainfall(double tRF, int SIZE)
{
	double aRF = 0;

	aRF = tRF/SIZE;

	return aRF;
}


void driestMonth(double rainfall [], int &dM, double &lowest)
{
	lowest = rainfall[0];

	for (int count = 1; count < SIZE; count++)
	{ 
		if (rainfall[count] < lowest)
		{
			lowest = rainfall[count];
			dM++;
		}
	}
	
}


void wettestMonth(double rainfall [], int &wM, double &highest)
{
	highest = rainfall[0];

	for (int count = 1; count < SIZE; count++)
	{ 
		if (rainfall[count] > highest)
		{
			highest = rainfall[count];
			wM ++;
		}
	}

}
Actually, I'm not a dude <:)
But, please, what is your current problem? (E.g : averageRainfall)?

Lol sorry! I'm used to calling everyone dude. Apologies. When I run the program without the averageRainfall function commented, it fails and gives me 2 errors:

Error 1 error LNK2019: unresolved external symbol "double __cdecl averageRainfall(double * const,int)" (?averageRainfall@@YANQANH@Z) referenced in function _main C:\Users\Mac\Desktop\VSProjects\Ch8PC7Final\Ch8PC7Final\8_7_FSource.obj Ch8PC7Final


Error 2 error LNK1120: 1 unresolved externals C:\Users\Mac\Desktop\VSProjects\Ch8PC7Final\Debug\Ch8PC7Final.exe Ch8PC7Final


So I'm not sure what is wrong... I'm new at this btw
I'm sorry, I found my error. Thanks anyway!
Here's my code if anyone would like to review it.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <string>

using namespace std;

//Global V&C
const int SIZE= 12;

void welcome();
void getData (double [], int qty);
double totalRainfall(double [], int qty);
double averageRainfall(double &tRF, int SIZE);
void wettestMonth(double [], int &wM, double &highest);
void driestMonth(double [], int &dM, double &lowest);

int main()
{
	//V&C
	double rainfall[SIZE];
	double tRF = 0, aRF = 0, lowest, highest;
	int  wM = 0 , dM = 0;
	string month[12] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};


	welcome();

	//Input
	getData(rainfall, SIZE);

	tRF = totalRainfall(rainfall, SIZE);

	aRF = averageRainfall(tRF, SIZE);

	wettestMonth(rainfall, wM, highest);

	driestMonth(rainfall, dM, lowest);

	//Output
	cout<<fixed<<setprecision(2);
	cout<<endl<<"The Rain Report for Neversnows County"<<endl;
	cout<<"-------------------------------------"<<endl;
	cout<<"Total rainfall for the year: "<<tRF<<" inches"<<endl;
	cout<<"Average rainfall for the year: "<<aRF<<" inches"<<endl;
	cout<<"The least amount of rain fell in "<<month[dM]<<" with "<<lowest<<" inches"<<endl;
	cout<<"The most amount of rain fell in "<<month[wM]<<" with "<<highest<<" inches"<<endl;
	cout<<"-------------------------------------"<<endl;

	return 0;

}



void welcome ()
{
	cout << "Welcome to the Rainfall Statistics Program "<<endl;
	return;
}

void getData (double rainfall [], int SIZE)
{
	int count;

	cout<< "Please enter the amount of inches of rainfall for the year.\n(Please hit the Return key after each input)"<<endl;
	for (count = 0; count < SIZE; count++)
	{
		cin>> rainfall[count];

		//Validation
		if (rainfall[count] < 0)
		{
			cout << "Please only use positive numbers." << endl;
			cin>> rainfall[count];
		}

	}

}


double totalRainfall(double rainfall [], int SIZE)
{
	int count;
	double tRF = 0;

	for (count = 0; count < SIZE; count++)
	{
		tRF += rainfall[count];
	}
	return tRF;
}


double averageRainfall(double &tRF, int SIZE)
{
	double aRF = 0;

	aRF = tRF/SIZE;

	return aRF;
}


void driestMonth(double rainfall [], int &dM, double &lowest)
{
	lowest = rainfall[0];

	for (int count = 1; count < SIZE; count++)
	{ 
		if (rainfall[count] < lowest)
		{
			lowest = rainfall[count];
			dM++;
		}
	}
	
}


void wettestMonth(double rainfall [], int &wM, double &highest)
{
	highest = rainfall[0];

	for (int count = 1; count < SIZE; count++)
	{ 
		if (rainfall[count] > highest)
		{
			highest = rainfall[count];
			wM ++;
		}
	}

}
Topic archived. No new replies allowed.