// 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.

Code:

// 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

	   ClearScreen();

	   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;
      getline(cin,filename);
      PressEnter();

      // Open the file
      inputfile.open(filename.c_str());

      // Check to see if the file can be found

      if(!inputfile)
      {
      ClearScreen();
      cerr << "File not found!" << endl;
      PressEnter();
      abort();
      }

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

 inputfile.close();
	   return;
} // end Input function


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

   // postcondition:
   {
 for()
{


}

 return;
} // 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.