Question: I am trying to run a code and it keep on saying that there in an unresolved external symbol. I am using visual studio. Can

I am trying to run a code and it keep on saying that there in an unresolved external symbol. I am using visual studio. Can anyone please help?

#include

#include

#include

using namespace std;

struct Data

{

string Name;

double Grade;

};

void getData(Data *, int);

void selectionSort(Data *, int);

double getAverage(Data *, int);

void displayData(Data *, int, double);

int main()

{

Data *Test;

double Average;

int Scores;

cout << "How many scores do you have to average? ";

cin >> Scores;

Test = new Data[Scores];

getData(Test, Scores);

selectionSort(Test, Scores);

Average = getAverage(Test, Scores);

displayData(Test, Scores, Average);

delete[] Test;

Test = 0;

return 0;

}

void getData(Data *Test, int Scores)

{

cout << "Enter the names and scores for each student. ";

for (int i = 0; i < Scores; i++)

{

cout << "Student #" << (i + 1) << endl;

cout << " Name: ";

cin.ignore();

getline(cin, (Test + i)->Name);

do

{

cout << " Score :";

cin >> (Test + i)->Grade;

if ((Test + i)->Grade < 0)

{

cout << "Scores must be greater than 0. "

<< "Re-enter ";

}

cout << endl;

} while ((Test + i)->Grade < 0);

}

}

void selectionSort(Data *Test, int Scores)

{

int startscan, minIndex;

Data minValue;

for (startscan = 0; startscan < (Scores - 1); startscan++)

{

minIndex = startscan;

minValue = Test[startscan];

for (int i = startscan + 1; i < Scores; i++)

{

if ((Test + i)->Grade < minValue.Grade)

{

minValue = Test[i];

minIndex = i;

}

}

Test[minIndex] = Test[startscan];

Test[startscan] = minValue;

}

}

double getAverage(Data *Test, int Scores)

{

double Total;

for (int i = 0; i < Scores; i++)

{

Total += (Test + i)->Grade;

}

return Total / Scores;

}

void displayData(Data *Test, int Scores, double Avg)

{

cout << " Test scores ";

cout << "Number of scores: " << Scores << endl;

cout << "Scores in ascending-order: ";

for (int i = 0; i < Scores; i++)

{

cout << (Test + i)->Name << ": " << (Test + i)->Grade << endl;

}

cout << fixed << showpoint << setprecision(2);

cout << "Average of scores: " << Avg << endl;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!