Here is my project: Write a program that dynamically allocates an array large enough to hold a user defined number of structures (string name and three double tests). Using a function, the user will enter a name and 3 test scores for each element in the array. Using another function, the user will sort the array into ascending order by name. Using a third function a table will be displayed on the screen(under a header labeling each column) showing:

Name Test1 Test2 Test3 Average

Then average for each element(three test grades/3) will be calculated by a 4th function as it is being displayed.

Please help! Here's what I have so far not sure about some of the code. I am new to this and honestly am quite lost. I would gladly appreciate any help anyone can give. I can't get my program to compile. Here's what I've got so far:

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

void sort(double*, int);
void drop(double*, int);
double average(double*, int);

int main()
{

char ch;
char name[30];
int numTestScores;
vector <string> names
string *studentNames;
double *testScorePtr;
double testAverage;

//Get the number of test scores
cout << "How many test scores will you enter? ";
cin >> numTestScores;
//Validate the input
while(numTestScores < 0)
{
cout << "Please re-enter a positive number other than zero. ";
cin >> numTestScores;
}
//Allocate an array to hold the test scores

std::vector <std::string> studentNames(numTestScores); 
std::vector <double> testScorePtr(numTestScores); 
for(int i=0; i<numTestScores; i++)
{
cout << "Enter the name and test score for test # "
<< (i+1) << " : " << endl;
std::getline(std::cin, studentNames[i]); 
studentNames[i] = name; 
cout << studentNames[i] <<endl;
cin.get(); 
}
/*//Get a test score.
cout << "Enter test score "
<< (i+1) << " : " << endl; 
cin >> testScorePtr[i]; */
//Validate the input. 

/*
while (numTestScores < 0)
{
cout << "Please re-enter a positive number other than zero. ";
cin >> testScorePtr[i];
}
*/

// Sort the test scores. 
sort(testScorePtr, numTestScores); 
//Display the resulting data. 
cout << "\nThe test scores in ascending "
<< "order, and their average, are:\n\n"; 
cout << "Score" << endl;
cout << "----" <<endl; 
for (int j = 0; j < numTestScores; j++) 
{
cout << "\n" << fixed << setprecision(2);
cout << setw(6) << testScorePtr[j]; 
}
// Get the average of the test scores. 
testAverage = average(testScorePtr, numTestScores); 
cout << "\n\nAverage score: ";
cout << setprecision(2) << fixed << testAverage <<endl; 
// Free the dynamically-allocated memory. 
delete [] testScorePtr;
testScorePtr = 0; 
return 0; 
}
double average(double* score, int numScores)
{
double total = 0; //Accumulator 
numScores--; 
//Calculate the total of the scores.
for (int k = 0; k <= numScores ; k++) 
{
total += score[k]; 
}
//Return the average score. 
return (total/numScores); 
}

I believe you're missing a semi-colon at the end of line 17. And, you're attempting to reuse a variable name in line 34 that you've already used in line 19.

Fixing these should at least get you to compile.

[boilerplate_help_info]

Posing requests for help must be well thought out if you want help quickly and correctly.  Your post did not meet the criteria for quality help. You may get some posts, but are they going to be useful?  Check your post with these checkpoints - what is it [i]you[/i] missed:
[list=1]
[*]Ask a question that can be answered. Do not ask
- What's wrong with my code?
- Why doesn't this work?
- Anything else that does not give us useful information
[*]Post your code.  If we don't know what you did, how can we possibly help?
- Use [b]PROPER FORMATTING[/b] -- see this
- Use CODE Tags so your formatting is preserved.
If we can't follow your code, it's difficult to help. We don't care that you're still working on it. If you want us to read it, it must be readable
[*]Explain what the code is supposed to do.  If we don't know where the target is, how can we help you hit it?
[*]Explain what actually happened! If we don't know where the arrow went when you shot it, how can we tell what went wrong and how far from the target you are?
[*]If you have errors, post them! We can't see your screen.  We can't read your mind. You need to tell us what happened.
[*]To [b]not[/b] ask for code. We are not a coding service. We will help you fix your code. 
    If anyone posts working code for you, they are a cheater. 
    If you use that code [i]you[/i] are a cheater.
[*]Do [b]not[/b] bore us with how new you are. We can tell by your code.
- Do not apologize. We were all new, and unless you are completely 
  brain dead you will get better.
- Do not ask us to "take it easy on you."
- Do not say "I don't know what's going on." That's obvious since
  you posted for help. Use that time wisely by [b]explaining[/b] as best 
  you can so we can help.
[*][b]Do not post your requirements and nothing else. [/b]We view that as a lazy do-nothing student that wants us to do their work for them. That's cheating and we [i]will[/i] be hard on you.
[*][b]Do not tell us how urgent it is.[/b] Seriously, for us there is no urgency at all. Many that can help will ignore any URGENT or ASAP requests.
[/list]
Think more about your next post so we don't have to play 20 questions to get the info we need to help you.

[/boilerplate_help_info]

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.