Doesn't compile

My code doesn't compile, I'm pretty sure the error is in the *inputscores function. Can someone tell me what I did wrong?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
  #include <iostream>
#include <string>
using namespace std;

struct Student
{
	string name;	// name of student
	int ID;		// student ID
	int* tests;		// Pointer to an array of test scores 
	double average;		// Average test score
	char grade;		// Grade
};

int numStudents();
int Tests();
string inputName();
int inputID();
int *inputScores(int);
double calcAverage(int*, int);
char calcGrade(double);
void display(Student*, int);

int main()
{
	Student *studentList;
	int size = numStudents();
	studentList = new Student[size];

	//Holds number of tests
	int numTests = Tests();

	for (int count = 0; count < size; count++)\
	{
		studentList[count].name = inputName();
		studentList[count].ID = inputID();
		studentList[count].tests = inputScores(numTests);
		studentList[count].average = calcAverage(studentList[count].tests, numTests);
		studentList[count].grade = calcGrade(studentList[count].average);
	}

	display(studentList, size);

	delete[] studentList;

	system("pause");
	return 0;

}

int numStudents()
{
	int students;
	cout << "How many students are there?" << endl;
	cin >> students;

	return students;
}

int tests()
{
	int tests;
	cout << "How many tests will there be?" << endl;
	cin >> tests;

	return tests;
}

string inputName()
{
	string name;
	cout << "How many tests will there be?" << endl;
	cin >> name;

	return name;
}

int inputID()
{
	int ID;
	cout << "What is the student's ID number?" << endl;
	cin >> ID;

	return ID;
}

int *intputScores(int numTests)
{
	int *scores;
	scores = new int[numTests];

	cout << "Enter the test scores for the student. Press Enter after each score." << endl;

	for (int count = 0; count < numTests; count++)
	{
		cout << "Score " << (count + 1) << ": ";
		cin >> scores[count];
	}

	return scores;
}

double calcAverage(int *testScores, int numTests)
{
	int total = 0;
	double average;
	
	for (int count = 0; count < numTests; count++)
	{
		total += testScores[count];
	}

	average = total / numTests;
	return average;

} 

char calcGrade(double average) {

	char letterGrade;

	if (average > 90 && average <= 100)
		letterGrade = 'A';
	else if (average > 80 && average <= 90)
		letterGrade = 'B';
	else if (average > 70 && average <= 80)
		letterGrade = 'C';
	else if (average > 60 && average <= 70)
		letterGrade = 'D';
	else if (average >= 0 && average <= 60)
		letterGrade = 'F';
	else {
		cout << "Logic error." << endl;
		// system("pause");
		exit(EXIT_FAILURE);
	}

	return letterGrade;
}

void display(Student *studentList, int size)
{
	for (int count = 0; count < size; count++)
		cout << studentList[count].name << " " << studentList[count].ID << " "
		<< studentList[count].average << " " << studentList[count].grade << endl;

	return;
}
what error do you get ?
Typo on line 86 in the function name
intputScores vs.
inputScores
Last edited on
Fixed the typo, thank you. but now I get this error.


Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol "int __cdecl Tests(void)" (?Tests@@YAHXZ) referenced in function _main Ch11_DD.cpp C:\Users\Dominick\source\repos\Ch11_DD.cpp\Ch11_DD.cpp\Ch11_DD.obj 1
C++ is case sensitive, you declare int Tests(); on line 15, but define int tests() starting on line 59.

If you get similar errors, try looking for inconsistencies or typos like this.
Topic archived. No new replies allowed.