i need a function to line up the info with these columns.:

Name Test 1 Test 2 Test 3 Average

here is the code that i have so far.:

#include <iostream>
#include <iomanip>
  
using namespace std;
   
void arrSelectSort(float *, int);
void showArrPtr(float *, int);
void showAverage(float, int);
  
int main()
  {
  float *scores, //To dynamically allocate an array
        total=0.0, //Accumulator
        average; //To hold the average scores
  int numScores; //To hold the number of test scores
      //Get the number of test scores.
      cout << "How many test scores would you like to process? ";
      cin >> numScores;
      
      //Dynamically allocate an array large enough to hold that many
      //test scores
      scores = new float[numScores];
      if(scores==NULL)
      return 0;
  
      //Get the test score for each test
      cout << "Enter the test scores below.\n";
      for (int count = 0; count < numScores; count++)
      {
         cout << "Test score #" << ( count + 1 ) << ": ";
         cin >> scores[count];
         while (scores <=0)
         {
                 cout << "Zero or negative numbers not accepted.\n";
                 cout << "Test Score #" << (count + 1) << ": ";
                 cin >>scores[count];
         }
      }
  
      //Calculate the total scores
      for (int count = 0; count < numScores; count++)
      {
                 total += scores[count];
      }
 
      //sort the elements of the array pointers
      arrSelectSort ( scores, numScores );
  
      //Will display them in sorted order.
      cout << "The test scores in ascending order are: \n";
  
      showArrPtr ( scores, numScores );

      showAverage( total, numScores );
  
      //Free memory.
  
      delete [] scores;
      system("pause");
      return 0;
}
void arrSelectSort(float *array, int size)
{
      int startScan, minIndex;
      float minElem;
  
      for (startScan = 0; startScan < ( size - 1 ); startScan++)
      {
              minIndex = startScan;
              minElem = array[startScan];
  
              for (int index = startScan + 1; index < size; index++)
              {

                       if ( array[index] < minElem)
                       {
                               minElem = array[index];
                               minIndex = index;
                       }
               }
               array[minIndex] = array[startScan];
               array[startScan] = minElem;
       }
}
void showArrPtr(float *array, int size)
{
       for (int count=0; count< size; count++)
               cout << array[count] << " ";
               cout << endl;
  
}
void showAverage(float total, int numScores)
{
       float average;
  
       //Calculate the average
       average = total / numScores;
 
       //Display the results.
       cout << fixed << showpoint << setprecision(2);
       cout << "Average Score: " << average << endl;
}

thanks to anyone who helps me with this.

Edited 6 Years Ago by WaltP: Fixed CODE tags again. I repeat -- Use the PREVIEW button.

Comments
Follow the rules and the mods won't act like "stupid jerk"s.....jerk...
I can't be bothered pressing report post to hassle the poor mods to fix your goddam code tags. I normally wait for 10 posts before giving -ve rep for lack of code tags - merry xmas!

i need a function to line up the info with these columns.:

Name Test 1 Test 2 Test 3 Average

here is the code that i have so far.:

####

thanks to anyone who helps me with this.

I don't see any attempt. There is nothing to help with yet.

And stop screwing up your CODE tags. They aren't that hard to use.

Comments
He's a mod enforcing the rules...
he acts like a stupid jerk.

You've already included the iomanip header. Do some more research on it. Every thing you need is in that header.

Edited 6 Years Ago by Fbody: n/a

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