Hi, I need help with a Golf Stats Program I am trying to complete. It is a dat file. My averaging functions are not working. Can someone suggest what I can do to correct the problems with both averaging functions?

main

#include <iostream>
using std::cerr;
using std::cout;
using std::cin;
using std::endl;
using std::fixed;
using std::ios;
using std::showpoint;

#include <fstream> // file stream        
using std::ifstream; // input file stream
#include <iomanip>
using std::setw;
using std::setprecision;

#include <string>
using std::string;

#include <cstdlib>
using std::exit; // exit function prototype
#include "golfers.h"

enum RequestType{LEGAL_SCORE=1, SCORE_PAR,AVG_HAND,AVG_SCORE,AT_HANDI,WORSE_HANDI,BETTER_HANDI,ILL_VALUE, END};

int main()
{
	golfers g;
    // ifstream constructor opens the file          
    ifstream inGolfersFile( "golf.dat" );

    // exit program if ifstream could not open file
    if ( !inGolfersFile )
    {
       cerr << "File could not be opened" << endl;
       exit( 1 );
    } // end if

	int request;
    int handi;
    int par;
    int score;
	int count;

	request = g.getRequest();
	while(request !=END)
	{
		switch(request)
		{
			case LEGAL_SCORE:
				cout << "\nThe number of legal golf scores above par: \n";
				break;
			case SCORE_PAR:
				cout << "\nThe number of legal golf scores par or lower: \n";
				break;
			case AVG_HAND:
				cout << "\nThe average of all handicaps for the golfers: \n";
				g.calcAvgHandi(handi, count);
				break;
			case AVG_SCORE:
				cout << "\nThe average of all scores for the golfers: \n" ;
				g.calcAvgScore(score, count);
				break;
				case AT_HANDI:
				cout << "\nThe number of golfers who scored at their handicap: \n";
				break;
			case WORSE_HANDI:
				cout << "\nThe number of golfers who scored worse than their handicap: \n";
				break;
			case BETTER_HANDI:
				cout << "\nThe number of golfers who scored better than their handicap: \n";
				break;
			case ILL_VALUE:
				cout << "\nThe number of illegal values found: \n";
				break;

				while(!inGolfersFile.eof())
					//display info
					if(g.getRequest())
						g.golfInfo( handi, par, score );
				inGolfersFile >> handi >> par >> score;
		}
		inGolfersFile.clear(); // reset
		inGolfersFile.seekg(0);
		request=g.getRequest(); 
	}
	return 0;
} // end of main
.h file
class golfers
{
public:
	golfers(void);
	void golfInfo( float, int, float ); // prototype
	bool golfDisplay(int);
	int getRequest();
	float calcAvgHandi(int[],int);
	float calcAvgScore(int,int);

	


private:
	int count;
	int handi;
	int par;
	int score;
	int request;
	
};

class golfers.cpp file

#include "golfers.h"
#include <iostream>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;
using std::fixed;
using std::ios;
using std::left;
using std::right;
using std::showpoint;

#include <fstream> // file stream        
using std::ifstream; // input file stream
#include <iomanip>
using std::setw;
using std::setprecision;

#include <string>
using std::string;

#include <cstdlib>
using std::exit; // exit function prototype

enum RequestType{LEGAL_SCORE=1, SCORE_PAR,AVG_HAND,AVG_SCORE,AT_HANDI,WORSE_HANDI,BETTER_HANDI,ILL_VALUE, END};


golfers::golfers(void)
{
}

// display golfers information file 
void golfers::golfInfo( float handi, int par, float score )
 {
    cout << right << setw( 10 ) << setprecision(1) << handi << setw( 13 ) << par
       << setw( 13 ) << setprecision( 2 ) << right << score << endl;
 } // end function golfInfo

int golfers::getRequest()
{
	int request;

	cout << "\nEnter request" << endl
	<< " 1 - List the number of legal golf score above par" << endl
	<< " 2 - List the number of legal golf score par or lower" << endl
	<< " 3 - Lists tha average of all handicaps for the golfers"  << endl
	<< " 4 - Lists tha average of all scores for the golfers" << endl
	<< " 5 - Lists the number of golfers who scored at their handicap" << endl
	<< " 6 - Lists the number of golfers who scored worse than their handicap" << endl
	<< " 7 - Lists the number of golfers who scored better than their handicap" << endl
	<< " 8 - Lists the number of illegal values found" << endl
	<< " 9 - END" << fixed << showpoint;

	do
	{
		cout << "\nEnter:  ";
		cin >> request;
	}
	while (request < LEGAL_SCORE && request > END);
	return request;
} // end function get Request


bool golfers::golfDisplay(int request)
{
	if(request==LEGAL_SCORE)
		return true;
	if(request==SCORE_PAR)
		return true;
	if(request==AVG_HAND)
		return true;
	if(request==AVG_SCORE)
		return true;
	if(request==AT_HANDI)
		return true;
	if(request==WORSE_HANDI)
		return true;
	if(request==BETTER_HANDI)
		return true;
	if(request==ILL_VALUE)
		return true;


	return false;
}

float golfers::calcAvgHandi(int handi [], int count)
{
	int sum=0;
	count = 0;
	float average;
	for (int i = 0; i < count; i++)
		sum = sum + handi[i];
	average = float(sum)/count;
	return average;
}
float golfers::calcAvgScore(int score[],int count)
{
	int sum=0;
	count = 0;
	float average;
	for (int i = 0; i < count; i++)
		sum = sum + score[i];
	average = float(sum)/count;
	return average;
}

errors

>.\.cpp(69) : error C2664: 'golfers::calcAvgHandi' : cannot convert parameter 1 from 'int' to 'int []'
1>        Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
1>.\.cpp(91) : warning C4244: 'argument' : conversion from 'int' to 'float', possible loss of data
1>.\.cpp(91) : warning C4244: 'argument' : conversion from 'int' to 'float', possible loss of data
1>Generating Code...
1>Build log was saved at "file://c:\Users\moporho\Documents\Visual Studio 2005\Projects\\Debug\BuildLog.htm"
1> - 2 error(s), 2 warning(s)
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

dat file

12  72  87
11  71  81
6   70  78
19  70  89
38  71 109
35  72 110
 1  72  73
 8  72  81
 9  72  83
 5  71  76
 4  72  76
14  71  88
20  72  90
22  72  97
31  70  103
34  72  108
22  72  96
23  73  96
21  71  92
17  72  90
16  72  85
15  71  85
12  71  83
11  70  83
10  71  84
 9  72  81
 8  69  77
 0  72  71
25  72  98
24  72  96
29  71  100
33  66  99
31  71  104
 1  62  60
 0  62  59
14  72  85
14  72  85
14  72  83
14  72  84
14  72  89
15  72  90
15  72  91
16  72  90
16  72  89
14  72  79
14  72  78
15  72  85

Thanks,
M

line 57 main.cpp: g.calcAvgHandi(handi, count);
handi is an int, not an array. Similar problems with the other lines.

Help! This is my last project in C++ and I am so lost!!

My data is not being read and all my functions are not computing correctly. Oh heck, my functions are a total mess.

Please someone have a look and help me get this thing working correctly.

11	#include <iostream>			
12	#include <iomanip>			
13	using std::setw;			
14	using std::setprecision;			
15	#include <fstream> // access to file related functions and types			
16	#include <cstdlib>  			
17				
18	//assert contains routines that allow the programmer to make 			
19	//assertions that must be true for program execution to continue			
20	#include <cassert>			
21				
22	using namespace std;  			
23				
24	const int MAX_GOLFERS = 47;     //1 student's scores are stored in a row			
25	const int STATS = 3;       //Each row has this many columns (scores)			
26				
27				
28	void seeStats(int table[][STATS],			
29	          int &number_of_golfers,			
30	          int &handicaps,			
31			  int &par,	
32			  int &scores);   //read data into a table	
33				
34	void print_a_row(int row[], int columns_to_print);			
35				
36				
37	void PrintStats(int table[][STATS],			
38				
39				
40				
41	int scoresAbovePar(const int STATS[47], int handicaps, int scores, int par, int count);			
42	int scoresAtOrPar(const int STATS[47], int handicaps, int scores, int par, int count);			
43	float avgHand(const int STATS[], int handicaps, int count);			
44	float avgScore(int table[], int scores, int count);			
45	int scoreAtHand(const int STATS[47], int handicaps, int scores, int par, int count);			
46	int scoreWorse(const int STATS[47], int handicaps, int scores, int par, int count);			
47	int scoreBetter(const int STATS[47], int handicaps, int scores, int par, int count);			
48	int illValue(const int STATS[47], int handicaps, int scores, int par, int count);                                      			
49				
50	int main(void)			
51	{			
52	    int table[MAX_GOLFERS][STATS]; // stats table			
53	    int number_of_golfers,  			
54	        handicaps,			
55			par,	
56			scores;	
57		int rows_to_print=47;		
58		int columns_to_print=3; 		
59	                			
60		// read stats		
61	    seeStats(table, number_of_golfers, handicaps, par, scores);			
62	    cout << "Golfer's Stats: \n\n"; 			
63	    			
64		PrintStats(table, rows_to_print,columns_to_print);		
65	    cout << "\nPress ENTER key to continue: \n";			
66	    cin.get();			
67				
68		cout << "1. - The number of legal golf scores above par is  " << scoresAbovePar << endl << endl;		
69				
70		cout << "2 - The number of legal golf scores at or below par is  " << scoresAtOrPar << endl << endl;		
71				
72		cout << "3. - The average of all handicaps for the golfers is " << setprecision(1) << avgHand << endl << endl;		
73				
74		cout << "4. - The average of all scores for the golfers is " << setprecision(2) << avgScore << endl << endl;		
75				
76		cout << "5. - The number of golfer who scored at their handicap is  " << scoreAtHand << endl << endl;		
77				
78		cout << "6. - The number of golfers who scored worse than their handicap is  " << scoreWorse << endl << endl;		
79				
80		cout << "7. - The number of golfers who scored better than their handicap is " << scoreBetter << endl << endl;		
81				
82		cout << "8. - The number of illegal values found is  " << illValue << endl << endl;		
83				
84				
85				
86	    return 0;			
87	} // end of main			
88				
89				
90	// function seeStats 			
91	void seeStats(int table[][STATS],			
92	              int &number_of_golfers,			
93	              int &handicaps,			
94				  int &par,
95				  int &scores)   
96	{             			
97	  //Open external data file for reading			
98	    ifstream infile("golf.dat");			
99	    if (!infile.is_open())  {			
100	      cerr << "File could not be opened" << endl;			
101	      exit(1);  // function in cstdlib			
102	    }			
103	  // read data into table			
104	    int row=0;			
105	    int column=0;			
106				
107	    while (infile >> table[row][column]) { 			
108	        if (infile.peek() != '\n') {			
109	          column++;  //more scores exist on line, advance column       			
110	        }			
111	        else { //end of line detected...			
112	          handicaps = column + 1; // set actual number of columns			
113	          column = 0; //start at beginning of next row			
114	          row++;			
115	        }        			
116	    } // end of while			
117	    number_of_golfers = row; // set actual number of rows			
118	} // end of seeStats			
119				
120	//print one row of the table.			
121	void print_a_row(int row[], int columns_to_print)			
122	{			
123	    for (int j = 0; j < columns_to_print; j++)			
124	        cout << setw(4) << row[j];    			
125	}			
126				
127	//function PrintStats			
128	void PrintStats(int table[][STATS],			
129	                int rows_to_print,			
130	                int columns_to_print)			
131	{       			
132	    for (int i = 0; i < rows_to_print; i++) {			
133	        print_a_row(table[i], columns_to_print);           			
134	        cout << endl;			
135	    }    			
136	} // end of PrintStats			
137				
138	int scoresAbovePar(const int STATS[47], int handicaps, int scores, int par, int count)			
139	{			
140		int i;		
141		i = scores - handicaps;		
142		i = i- par;		
143				
144		if (i >= handicaps)		
145			count++;	
146				
147	return count;			
148	}			
149	int scoresAtOrPar(const int STATS[47], int handicaps, int scores, int par, int count)			
150	{			
151		int i;		
152		i = scores - handicaps;		
153		i = i- par;		
154				
155		if (i <= handicaps)		
156			count++;	
157				
158	return count;			
159	}			
160				
161	float avgHand(const int STATS[47], int handicaps, int count)			
162	{			
163		int sum=0;		
164		float avg;		
165				
166		for(int i=0; i < count; i++)		
167			sum = sum + STATS[i];	
168		avg = float(sum)/count;		
169				
170		return avg;		
171		} // end avgHand		
172				
173	float avgScore(int table[], int scores, int count)			
174	{			
175		int sum=0;		
176		float avg;		
177				
178		for(int i=0; i < count; i++)		
179			sum=sum+table[i];	
180		avg = float(sum)/count;		
181				
182		return avg;	// end avgScore	
183	}			
184				
185	int scoreAtHand(const int STATS[47], int handicaps, int scores, int par, int count)			
186	{			
187				
188		if (scores == scores-handicaps)		
189			count ++;	
190		return count;		
191	}			
192	int scoreWorse(const int STATS[47], int handicaps, int scores, int par, int count)			
193	{			
194				
195		if (scores < scores-handicaps)		
196			count ++;	
197		return count;		
198	}			
199	int scoreBetter(const int STATS[47], int handicaps, int scores, int par, int count)			
200	{			
201				
202		if (scores > scores-handicaps)		
203			count ++;	
204		return count;		
205	}			
206				
207	int illValue(const int STATS[47], int handicaps, int scores, int par, int count)			
208	{			
209		if (handicaps < 0 || handicaps > 36 || par < 62 || par >72 || scores < 60 || scores > 120)		
210				
211			count++;	
212				
213		return count;		
214	}

the data file is above.

here is the output I am getting

Golfer's Stats:

  12  72  87
  11  71  81
   6  70  78
  19  70  89
  38  71 109
  35  72 110
   1  72  73
   8  72  81
   9  72  83
   5  71  76
   4  72  76
  14  71  88
  20  72  90
  22  72  97
  31  70 103
  34  72 108
  22  72  96
  23  73  96
  21  71  92
  17  72  90
  16  72  85
  15  71  85
  12  71  83
  11  70  83
  10  71  84
   9  72  81
   8  69  77
   0  72  71
  25  72  98
  24  72  96
  29  71 100
  33  66  99
  31  71 104
   1  62  60
   0  62  59
  14  72  85
  14  72  85
  14  72  83
  14  72  84
  14  72  89
  15  72  90
  15  72  91
  16  72  90
  16  72  89
  14  72  79
  14  72  78
  15  72  85

Press ENTER key to continue:

1. - The number of legal golf scores above par is  004111B8

2 - The number of legal golf scores at or below par is  00411145

3. - The average of all handicaps for the golfers is 004110DC

4. - The average of all scores for the golfers is 004111C2

5. - The number of golfer who scored at their handicap is  004111BD

6. - The number of golfers who scored worse than their handicap is  00411046

7. - The number of golfers who scored better than their handicap is 004111D6

8. - The number of illegal values found is  004110EB

Press any key to continue . . .

Thank you,
M~

Please don't manually add line numbers because compilers don't like them. The code tags will insert line numbers for you. Please repost code without manual line numbers

[code=cplusplus] // put your code here

[/code]

Sorry, now that I know I will not ever do that again. I am sorry.

#include <iostream>
#include <iomanip>
using std::setw;
using std::setprecision;
#include <fstream> // access to file related functions and types
#include <cstdlib>  

//assert contains routines that allow the programmer to make 
//assertions that must be true for program execution to continue
#include <cassert>

using namespace std;  

const int MAX_GOLFERS = 47;     //1 student's scores are stored in a row
const int STATS = 3;       //Each row has this many columns (scores)


void seeStats(int table[][STATS],
          int &number_of_golfers,
          int &handicaps,
		  int &par,
		  int &scores);   //read data into a table

void print_a_row(int row[], int columns_to_print);


void PrintStats(int table[][STATS],
				int rows_to_print, 
				int columns_to_print);  // print golfers' stats in a table

int scoresAbovePar(const int STATS[47], int handicaps, int scores, int par, int count);
int scoresAtOrPar(const int STATS[47], int handicaps, int scores, int par, int count);
float avgHand(const int STATS[], int handicaps, int count);
float avgScore(int table[], int scores, int count);
int scoreAtHand(const int STATS[47], int handicaps, int scores, int par, int count);
int scoreWorse(const int STATS[47], int handicaps, int scores, int par, int count);
int scoreBetter(const int STATS[47], int handicaps, int scores, int par, int count);
int illValue(const int STATS[47], int handicaps, int scores, int par, int count);                                      

int main(void)
{
    int table[MAX_GOLFERS][STATS]; // stats table
    int number_of_golfers,  
        handicaps,
		par,
		scores;
	int rows_to_print=47;
	int columns_to_print=3; 
                
	// read stats
    seeStats(table, number_of_golfers, handicaps, par, scores);
    cout << "Golfer's Stats: \n\n"; 
    
	PrintStats(table, rows_to_print,columns_to_print);
    cout << "\nPress ENTER key to continue: \n";
    cin.get();

	cout << "1. - The number of legal golf scores above par is  " << scoresAbovePar << endl << endl;

	cout << "2 - The number of legal golf scores at or below par is  " << scoresAtOrPar << endl << endl;

	cout << "3. - The average of all handicaps for the golfers is " << setprecision(1) << avgHand << endl << endl;

	cout << "4. - The average of all scores for the golfers is " << setprecision(2) << avgScore << endl << endl;

	cout << "5. - The number of golfer who scored at their handicap is  " << scoreAtHand << endl << endl;

	cout << "6. - The number of golfers who scored worse than their handicap is  " << scoreWorse << endl << endl;

	cout << "7. - The number of golfers who scored better than their handicap is " << scoreBetter << endl << endl;

	cout << "8. - The number of illegal values found is  " << illValue << endl << endl;


		
    return 0;
} // end of main


// function seeStats 
void seeStats(int table[][STATS],
              int &number_of_golfers,
              int &handicaps,
			  int &par,
			  int &scores)   
{             
  //Open external data file for reading
    ifstream infile("golf.dat");
    if (!infile.is_open())  {
      cerr << "File could not be opened" << endl;
      exit(1);  // function in cstdlib
    }
  // read data into table
    int row=0;
    int column=0;
	
    while (infile >> table[row][column]) { 
        if (infile.peek() != '\n') {
          column++;  //more scores exist on line, advance column       
        }
        else { //end of line detected...
          handicaps = column + 1; // set actual number of columns
          column = 0; //start at beginning of next row
          row++;
        }        
    } // end of while
    number_of_golfers = row; // set actual number of rows
} // end of seeStats

//print one row of the table.
void print_a_row(int row[], int columns_to_print)
{
    for (int j = 0; j < columns_to_print; j++)
        cout << setw(4) << row[j];    
}

//function PrintStats
void PrintStats(int table[][STATS],
                int rows_to_print,
                int columns_to_print)
{       
    for (int i = 0; i < rows_to_print; i++) {
        print_a_row(table[i], columns_to_print);           
        cout << endl;
    }    
} // end of PrintStats

int scoresAbovePar(const int STATS[47], int handicaps, int scores, int par, int count)
{
	int i;
	i = scores - handicaps;
	i = i- par;

	if (i >= handicaps)
		count++;
		
return count;
}
int scoresAtOrPar(const int STATS[47], int handicaps, int scores, int par, int count)
{
	int i;
	i = scores - handicaps;
	i = i- par;

	if (i <= handicaps)
		count++;
		
return count;
}

float avgHand(const int STATS[47], int handicaps, int count)
{
	int sum=0;
	float avg;

	for(int i=0; i < count; i++)
		sum = sum + STATS[i];
	avg = float(sum)/count;
	
	return avg;
	} // end avgHand

float avgScore(int table[], int scores, int count)
{
	int sum=0;
	float avg;

	for(int i=0; i < count; i++)
		sum=sum+table[i];
	avg = float(sum)/count;

	return avg;	// end avgScore
}

int scoreAtHand(const int STATS[47], int handicaps, int scores, int par, int count)
{

	if (scores == scores-handicaps)
		count ++;
	return count;
}
int scoreWorse(const int STATS[47], int handicaps, int scores, int par, int count)
{

	if (scores < scores-handicaps)
		count ++;
	return count;
}
int scoreBetter(const int STATS[47], int handicaps, int scores, int par, int count)
{

	if (scores > scores-handicaps)
		count ++;
	return count;
}

int illValue(const int STATS[47], int handicaps, int scores, int par, int count)
{
	if (handicaps < 0 || handicaps > 36 || par < 62 || par >72 || scores < 60 || scores > 120)

		count++;

	return count;
}

M~

cout << "1. - The number of legal golf scores above par is  " << scoresAbovePar << endl << endl;

	cout << "2 - The number of legal golf scores at or below par is  " << scoresAtOrPar << endl << endl;

	cout << "3. - The average of all handicaps for the golfers is " << setprecision(1) << avgHand << endl << endl;

	cout << "4. - The average of all scores for the golfers is " << setprecision(2) << avgScore << endl << endl;

	cout << "5. - The number of golfer who scored at their handicap is  " << scoreAtHand << endl << endl;

	cout << "6. - The number of golfers who scored worse than their handicap is  " << scoreWorse << endl << endl;

	cout << "7. - The number of golfers who scored better than their handicap is " << scoreBetter << endl << endl;

	cout << "8. - The number of illegal values found is  " << illValue << endl << endl;

scoresAbovePar is a function, not a data element. All you are doing in the lines posted above is printing the address of those functions. You have to call them just as any other function.

I am sorry, I am not clear. How would a call to the function look? I am muttled up.

Like this: cout << "1. - The number of legal golf scores above par is " << scoresAbovePar( <parameter list here> ) << endl << endl;

I can not get the functions to produce the correct data. Can someone make suggestions?

#include "stdafx.h"
#include <iostream>
#include <iomanip>
using std::setw;
using std::setprecision;
#include <fstream> 
#include <cstdlib>  


#include <cassert>

using namespace std; 
		
const int MAX_GOLFERS = 47;    
const int STATS = 3;       


void seeStats(int table[][STATS],
          int &number_of_golfers,
          int &handicaps,
              int &par,
              int &scores);   //read data into a table

void print_a_row(int row[], int columns_to_print);


void PrintStats(int table[][STATS],
                        int rows_to_print, 
                        int columns_to_print);  // print golfers' stats in a table

int scoresAbovePar(const int table[STATS], int handicaps,int par, int scores,int count);
int scoresAtOrPar(const int table[STATS], int handicaps, int scores, int par, int count);
float avgHand(const int table[STATS], int handicaps, int count);
float avgScore(const int table[STATS], int scores, int count);
int scoreAtHand(const int table[STATS], int handicaps, int scores, int par, int count);
int scoreWorse(const int table[STATS], int handicaps, int scores, int par, int count);
int scoreBetter(const int table[STATS], int handicaps, int scores, int par, int count);
int illValue(const int table[STATS], int handicaps, int scores, int par, int count);                                      

int main(void)
{
    int table[MAX_GOLFERS][STATS]; // stats table
    int number_of_golfers,  
        handicaps,
            par,
            scores;
      int rows_to_print=47;
      int columns_to_print=3; 
	  int count=0;
                
      // read stats
    seeStats(table, number_of_golfers, handicaps, par, scores);
    cout << "Golfer's Stats: \n\n"; 
    
      PrintStats(table, rows_to_print,columns_to_print);
    cout << "\nPress ENTER key to continue: \n";
    cin.get();

     cout << "1. - The number of legal golf scores above par is  " << scoresAbovePar(table[STATS], handicaps,par, scores,count) << endl << endl;
	

      cout << "2 - The number of legal golf scores at or below par is  " << scoresAtOrPar(table[STATS], handicaps, scores, par, count) << endl << endl;

      cout << "3. - The average of all handicaps for the golfers is " << setprecision(1) << avgHand(table[STATS], handicaps, count) << endl << endl;

      cout << "4. - The average of all scores for the golfers is " << setprecision(2) << avgScore(table[STATS], scores, count) << endl << endl;

      cout << "5. - The number of golfer who scored at their handicap is  " << scoreAtHand(table[STATS], handicaps, scores, par, count) << endl << endl;

      cout << "6. - The number of golfers who scored worse than their handicap is  " << scoreWorse(table[STATS], handicaps, scores, par, count) << endl << endl;

      cout << "7. - The number of golfers who scored better than their handicap is " << scoreBetter(table[STATS], handicaps, scores, par, count) << endl << endl;

      cout << "8. - The number of illegal values found is  " << illValue(table[STATS], handicaps, scores, par, count) << endl << endl;


            
    return 0;
} // end of main


// function seeStats 
void seeStats(int table[][STATS],
              int &number_of_golfers,
              int &handicaps,
                    int &par,
                    int &scores)   
{             
  //Open external data file for reading
    ifstream infile("golf.dat");
    if (!infile.is_open())  {
      cerr << "File could not be opened" << endl;
      exit(1);  // function in cstdlib
    }
  // read data into table
    int row=0;
    int column=0;
      
    while (infile >> table[row][column]) { 
        if (infile.peek() != '\n') {
          column++;  //more scores exist on line, advance column       
        }
        else { //end of line detected...
          handicaps = column + 1; // set actual number of columns
          column = 0; //start at beginning of next row
          row++;
        }        
    } // end of while
    number_of_golfers = row; // set actual number of rows
} // end of seeStats

//print one row of the table.
void print_a_row(int row[], int columns_to_print)
{
    for (int j = 0; j < columns_to_print; j++)
        cout << setw(4) << row[j];    
}

//function PrintStats
void PrintStats(int table[][STATS],
                int rows_to_print,
                int columns_to_print)
{       
    for (int i = 0; i < rows_to_print; i++) {
        print_a_row(table[i], columns_to_print);           
        cout << endl;
    }    
} // end of PrintStats

int scoresAbovePar(const int table[STATS], int handicaps,int par, int scores,int count)
{
      int i;
      i = scores - handicaps;
      i = i- par;

      if (i >= handicaps)
            count++;
	             
return count;
}
int scoresAtOrPar(const int table[STATS], int handicaps, int scores, int par, int count)
{
      int i;
      i = scores - handicaps;
      i = i- par;

      if (i <= handicaps)
            count++;
            
return count;
}

float avgHand(const int table[STATS], int handicaps, int count)
{
      int sum=0;
      float avg;

      for(int i=0; i < count; i++)
            sum = sum + table[i];
      avg = float(sum)/count;
      
      return avg;
      } // end avgHand

float avgScore(const int table[STATS], int scores, int count)
{
      int sum=0;
      float avg;

      for(int i=0; i < count; i++)
            sum=sum+table[i];
      avg = float(sum)/count;

      return avg; // end avgScore
}

int scoreAtHand(const int table[STATS], int handicaps, int scores, int par, int count)
{

      if (scores == scores-handicaps)
            count ++;
      return count;
}
int scoreWorse(const int table[STATS], int handicaps, int scores, int par, int count)
{

      if (scores < scores-handicaps)
            count ++;
      return count;
}
int scoreBetter(const int table[STATS], int handicaps, int scores, int par, int count)
{

      if (scores > scores-handicaps)
            count ++;
      return count;
}

int illValue(const int table[STATS], int handicaps, int scores, int par, int count)
{
      if (handicaps < 0 || handicaps > 36 || par < 62 || par >72 || scores < 60 || scores > 120)

            count++;

      return count;
}

line 59: scoresAbovePar(table[STATS], handicaps,par, scores,count)

The first parameter is incorrect. Here's the correction:
scoresAbovePar(table, handicaps,par, scores,count)

I can not get it to run. it states

1>c:\users\moporho\documents\visual studio 2005\projects\rho_11_cpp\rho_11_cpp\rho_11_cpp.cpp(69) : error C2664: 'scoresAbovePar' : cannot convert parameter 1 from 'int [47][3]' to 'const int []'

Look at line 42: what do you see there? table is a two dimensional array.
Now look at line 31: the first parameter is a single dimensional array, not 2 dimension.

You will have to correct that inconsistency. I don't know which way you want it, but you can't have it both ways.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.