Could somebody please me get this to compile and run
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cmath>
using namespace std;
// global constant declaration
const int MAX_SIZE = 50;
const int NUM_RANGE = 25;
void getNumbers( int numbers[ ], int& size, int MAX_SIZE );
void printResults( float mean, float median, float mode );
void createFrequency(int scores [] , int size, int frequency[], int range);
void createHistogram(int frequency[], int range);
float calcMean(ofstream& inFile, int numbers, int size );
void sort (int list[], int last);
void bubbleUp(int list[], int current, int last);
float calcMedian(ofstream&, int list[], int);
float calcMode(ofstream& report, int freq[], int size);
int main( )
{
float mean = 0;
float median = 0;
float mode= 0;
int numbers[ MAX_SIZE ], size;
getNumbers( numbers, size,MAX_SIZE);
createFrequency(size,frequency[],NUM_RANGE);
createHistogram(frequency, NUM_RANGE);
mean=calcMean(ofstream& inFile, numbers, size );
sort (int list[], int last);
bubbleUp(int list[], int current, int last);
median = calcMedian(ofstream&, int list[], int);
mode = calcMode(ofstream& report, int freq[], int size);
printResults(mean, median, mode );
return 0;
}
//===============getNumbers========================
void getNumbers( int numbers[ ], int& size,int MAX_SIZE )
{
ofstream inFile;
size = 0;
inFile.open( "scores.txt" );
if ( !inFile )
{
cerr << "scores.txt cannot be opened" << endl;
exit( 100 );
}
while ( ( size < MAX_SIZE ) && ( inFile >> numbers[ size ] ) )
{
++size;
}
inFile.close( );
return;
}//end of getData
//===================Mean=======================
// finds the average of the numbers
float calcMean(ofstream & inFile, int numbers[ ], int size)
{
float total=0;
float mean;
for (int i=0;i<size;i++)
total= total+ numbers[i ];
mean =total/size;
return mean;
}//End of mean
//===============createFrequency========================
//Creates the frequency of scores
void createFrequency(int scores [] , int size, int frequency[],
int range)
{
for(int i = 0;i < size;i++)
frequency [scores[i]]++;
return;
}//end createFrequency
//===================createHistogram=======================
//Creates Histogram of scores
void createHistogram(int frequency[], int range)
{
for(int i = 0;i<=range;i++)
{
cout<<setw(3)<<i<<setw(3)<<frequency[i];
for(int j = 1;j<=frequency[i];j++)
{
cout<<"*";
cout<<endl;
}
}
return;
}//end createHistogram
//===================Median=======================
//find the median of scores
float calcMedian(ofstream& file, int list[], int size)
{
double median;
sort(list, size); // this will sort the list
if (size%2 ==0)
{
median = ((list[(size/2)+1]) + (list[size/2]))/2;
median = floor(median);
}
else
{
median = (float) (list[size/2]);
median = ceil(median);
}
return median;
}//end Median
//===================sort=======================
void sort(int list[], int last)
{
for(int current=0; current< last; current++)
bubbleUp(list, current, last);
return;
}//sort
//===============bubbleUp===============================
void bubbleUp(int list[], int current, int last)
{
for( int walker = last; walker > current; walker--)
if(list[walker] < list[walker-1])
{
int temp = list[walker];
list[walker] = list[walker-1];
list[walker-1] = temp;
}
return;
}//bubble sort
//=================mode=====================//
float mode (ofstream& file, int frequency[], int size)
{
int largest=0, mode;
for(int i = 0; i < size; i++)
{
if(frequency[i] > largest)
{
largest = frequency[i];
}
}
for(int i = 0; i < size; i++)
{
if(frequency[i] == largest)
mode = i;
}
return mode ;
}
//==============printResults==============
//prints out results
void printResults( float mean, float median, float mode)
{
cout<<"The mean is"<<setw(4)<<mean<<endl;
cout<<"The median is"<<setw(4)<<median<<endl;
cout<<"The mode is"<<setw(4)<<mode<<endl;
return;
}