Okay....Two questions. 1) What would be the best way to convert this app to where the user just types in names until they type "Quit" instead of typing in how many students there should be. 2) How could I break this down into a .h file, source file, and main?
Thanks for the quick reply! I'm not familiar with vectors at all. I would familiarize myself, but this is due at midnight tonight. This is all I have left though. That's what I thought for question 2...but when I do that the whole thing blows up.
Here is a list of errors:
4 N:\USB Files\USB Files\Spring 2014\C++ Homework\This Final\FinalMain.cpp In file included from FinalMain.cpp
4 N:\USB Files\USB Files\Spring 2014\C++ Homework\This Final\FinalHeader.h expected unqualified-id before '{' token
4 N:\USB Files\USB Files\Spring 2014\C++ Homework\This Final\FinalHeader.h expected `,' or `;' before '{' token
N:\USB Files\USB Files\Spring 2014\C++ Homework\This Final\FinalMain.cpp In function `int main()':
19 N:\USB Files\USB Files\Spring 2014\C++ Homework\This Final\FinalMain.cpp `grades' undeclared (first use this function)
(Each undeclared identifier is reported only once for each function it appears in.)
19 N:\USB Files\USB Files\Spring 2014\C++ Homework\This Final\FinalMain.cpp expected `;' before "gradeBook"
23 N:\USB Files\USB Files\Spring 2014\C++ Homework\This Final\FinalMain.cpp `inputStudents' undeclared (first use this function)
31 N:\USB Files\USB Files\Spring 2014\C++ Homework\This Final\FinalMain.cpp `inputName' undeclared (first use this function)
32 N:\USB Files\USB Files\Spring 2014\C++ Homework\This Final\FinalMain.cpp `inputScores' undeclared (first use this function)
33 N:\USB Files\USB Files\Spring 2014\C++ Homework\This Final\FinalMain.cpp `calcAverage' undeclared (first use this function)
34 N:\USB Files\USB Files\Spring 2014\C++ Homework\This Final\FinalMain.cpp `calcGrade' undeclared (first use this function)
37 N:\USB Files\USB Files\Spring 2014\C++ Homework\This Final\FinalMain.cpp `display' undeclared (first use this function)
38 N:\USB Files\USB Files\Spring 2014\C++ Homework\This Final\FinalMain.cpp `displayClassAverage' undeclared (first use this function)
The breaking up into separate files isn't as important as the typing "Quit" to stop accepting names. I want to break it up to make it look cleaner, but that's not a mandatory thing. However, the other part is a specific part of the assignment.
#include "Functions.h"
int main()
{
//Create a dynamic array of the GradeBook structure.
GradeBook *studentList;
int size = inputStudents();
studentList = new GradeBook[size];
//Create an array to hold the number of test scores for each student.
int numOfTests = 3;
for (int count = 0; count < size; count++)
{
studentList[count].name = inputName();
studentList[count].tests = inputScores(numOfTests);
studentList[count].average = calcAverage(studentList[count].tests, numOfTests);
studentList[count].grade = calcGrade(studentList[count].average);
}
display(studentList, size);
displayClassAverage(studentList, size);
delete[] studentList;
cout << endl;
system("Pause");
return 0;
}
What you did looks almost identical to mine, but yours works and mine doesn't... Well thanks so much softrix! Any idea on how to redo the input of the names? Aside from vectors :)
Well if you want to avoid Lists and Vectors the only other way would be to allocate some initial space and extend it as needed when you exceed the amount previously allocated.
If your not comfortable with pointers you may have a problem.