Need help writing this code with arrays!

I am a beginning computer science major and coming up on my final lab exam which is unknown exactly what it will be covering. I know that I really do not understand how to use 1D or 2D Arrays, I have been given a homework assignment that looks like this:

The head coach of a local baseball team would like to hire you to write a program that calculates the batting average of every player on his team. Below is the output that he would like displayed. Write a C++ program to accomplish this task. You must design the program yourself using the appropriate input, process, and output functions.

Player __AB__ HITS__ AVE
Allan ___521__192__.369
Brett ___493__180__.365
Carl____451__160__.354
Derek___590__205__.347
Mike____501__167__.333
Henry___485__156__.321
Paul____562__180__.320
Steve___499__159__.318
Josh____480__149__.310
Lee_____490__150__.306

Totals 5072__1698__.335

I really do not know how to use arrays and need help with this! I've watched videos, read in my textbook, and my professor showed us in class, I just can't grasp this for some reason. This is my last program before the final and I need to get this one working for a good study reference.. any help would be much appreciated!

this is what I have currently.
How do I allow the user to enter their own values to the array to create this table?


#include <iostream>
#include <string>
using namespace std;

//function prototypes
void getNames(string);
void getAverages();

//symbolic constants
float PlayerStat[10][3];



int main()
{
string name, dummy;


getNames(dummy);


}
void getNames(string dummy)
{
for (int i = 0; i < 5; i++)
{
cout << "Please enter the name's for the each player. " << endl;
getline(cin, dummy);
}
}
void getAverages()
{
for (int i = 0; i < 3; i++)
{
cout << "Please enter each players scores." << endl;
cin >>
}
}
Last edited on
Topic archived. No new replies allowed.