need another pair of eyes
Hi,
A student in my C++ class has this problem with his assignment. It's
supposed to print out a table with baseball stats: player name,
number, atbats, hits, and batting avg..
well his program looks good but i've been looking at so many i know
i'm missing something easy. his application is swaping the second and
third column data while leaving the headers alone.
in otherwords, he's listing the name and then the atbats is coming up
under the player number and the player number is showing up under the
at-bats. can someone please lend me a pair of eyes to show me what i'm
missing to help him?
thanks,
scrooge
----------------------------------------------------------------------------------------------------------------------------------------------------------
#include <iostream>
#include <iomanip>
#include <string>
using std::cin;
using std::cout;
using std::endl;
using std::left;
using std::setiosflags;
using std::setw;
using std::ios;
using namespace std;
//function prototypes
void displayHead();
void displayTopOfForm(string []);
void displayDataArray(string [][2], int [][2]);
int main()
{
//declare variables
int player[10][2] = {0};
int battAvg[10] = {0};
string playerName[10][2] = {{"Adam", "1"}, {"Ben", "2"}, {"Carl",
"3"}, {"Don", "4"}, {"Eric", "5"}, {"Frank", "6"}, {"Glenn", "7"},
{"Han", "8"}, {"Ian", "9"}, {"Jon", "10"}};
string header[5] = {"Player", "Number", "AtBats", "Hits", "BattAVG"};
//calculate batting average
//call display functions
displayHead();
cout << endl;
displayTopOfForm(header);
cout << endl << endl;
displayDataArray(playerName, player);
return 0;
} //end of main function
//*********************called functions**************************
//begin displayHead function
void displayHead()
{
cout << setw(52) << "Batting Average Program" << endl;
} //end displayHead function
//begin displayTopOfHeader function
void displayTopOfForm(string topForm[])
{
for (int i=0; i<5; i++)
{
cout << setiosflags(ios::right) << setw(14) << topForm[i];
}
} //end displayTopOfForm function
//displayArray function
void displayDataArray(string name[][2], int stats[][2])
{
for (int i=0; i<10; i++)
{
for (int j=0; j<2; j++)
{
cout << setiosflags(ios::left) << setw(14) << name[i][j]<< setw(14);
cout << stats[i][j] << setw(14);
}
cout << endl;
} //end for
} //end displayArray function
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]