// This is what I have so far, could you guys help me and give me tips on how to fix the Process. I don't know if i'm using the correct kind of loop or not. I am using C++. Its' supposed to read the files in from a .txt file which I already have and then it's supposed to calculate the average which I can't figure out how. All that doesn't work is the process, so if anyone has an advice at all.


// function prototypes

   void Input (int [], int [], int [], int [], int [], int);
   void Process (double[], int [], int [], int [], int[]);
   void Output();
   void SendMessage();
   void CloseOutput();

// program constants
   const int MaxSize = 10;

///////////////////////////// Level 0 ////////////////////////////////////

int main () //////////////////////////////////////////////////////////////
	// variable declarations
	int Number[MaxSize];
	int AtBats[MaxSize];
	int Hits[MaxSize];
	int Walks[MaxSize];
	int Outs[MaxSize];
	int count = 0;
	double average[MaxSize];
	int index;

	// execution section


	   Input(Number, AtBats, Hits, Walks, Outs, count);

	   Process (average, AtBats, Hits, Walks, Outs);

	   //Output ();

	return 0;
} // end main function
///////////////////////////// Level 1 ////////////////////////////////////

void Input (int Number[], int AtBats[], int Hits[], int Walks[], int Outs[], int count)
   // preconditions:   (What must be true before this function is called.)

   // postcondition:  (The effect of this function execution.)

      ifstream inputfile;
      apstring filename;

      cout << "Please enter the name of file to be opened." << endl;

      // Open the file

      // Check to see if the file can be found

      cerr << "File not found!" << endl;

	while(inputfile >> Number[count]);
	inputfile >> AtBats[count];
	inputfile.ignore(80, '\n');
	inputfile >> Hits[count];
	inputfile >> Walks[count];
	inputfile >> Outs[count];
	inputfile.ignore(80, '\n');
	count ++;

} // end Input function

void Process (double average[], int AtBats[], int Hits[] ,int Walks[], int Outs[])
   // preconditions:

   // postcondition:


} // end Process function

<< moderator edit: added code tags: [code][/code] >>

>and then it's supposed to calculate the average which I can't figure out how

The average is the sum divided by the total number of values that contributed to the sum.

This article has been dead for over six months. Start a new discussion instead.