I am writing a gradbook type program. It first allows the user to enter the number of students they want to enter. then allows them to enter the first name, last name, and grade of each student. The program then should sort the names alphabetically by last name and display a list of all the students names and grades in alphabetical order. I have completed all my functions and classes, but i am getting a god aweful amount of errors and i am not sure what is wrong. It is my first attempt at using classes and objects and bubble sort so i am not sure. here is my code let me know any problems you see, i would greatly appreciate some guidance. First is the header file
#include <iostream> // allows the program to output data to the screen
// students class definition
class students
{
public:
int arraySize; // size of array entered by user for number of students
int getNumstudents(int arraySize); // function to get the number of students user wants to enter
void getData(int arraySize); // function to get first and last name and the students grade
void displayMessage(); // displays welcome message
void sortData (); // function to alphabetize by last name using buble sort
void printData (); // function to print data
private:
char*firstName[arraySize]; // array of students first names
char*lastName[arraySize]; // array of students last names
int grades[arraySize]; // array of students grades
};
and here is the cpp file
#include <iostream> // allows the program to output data to the screen
#include <conio.h>
#include <iomanip>
#include <cstdlib>
#include <string.h>
#include "students.h" // gradebook class defintion
using std::cout; // program uses cout
using std::cin; // program uses cin
using std::endl; // program uses endl
using std::setprecision; // set numeric output precision
using std::fixed; // ensures that decimal point is displayed
using std::setw;
void students::displayMessage()
{
cout << "Welcome to the Student Scores Application." << endl;
}
// sorts data alphabetically by last name using bubble sort
void students::sortData()
{
for(int i = 0; i < arraySize ; i++){
for(int j = i+1; i < arraySize; j++){
if(strcmp(lastName[i]){
char *temp = lastName[i]; // swap pointers
lastName[i] = lastName[j];
lastName[j] = temp;
}
}
}
}
// Prints all the students data
void students::printData()
{
for (int i = 0; i < arraySize; i++)
{
cout << "Student " << num << " last name: " << lastName[i] <<", " << firstName[i] << ": " << grades[i] << endl;
}
}
// gets the number of students the user wnats to enter and sets that as the arraysize
int students::getNumstudents(int arraySize)
{
cout << "Enter number of students to enter: ";
cin >> arraySize;
}
// gets students info from user
void students::getData(int arraysize)
{
int num = 1;
char*userinput1;
char*userinput2;
int userinput3;
while ( num <= arraySize){
cout << "Student " << num << " last name: ";
lastName[arraysize] = userinput1;
cout << "Student " << num << " first name: ";
firstName[arraysize] = userinput2;
cout << "Student " << num << " score: ";
grades[arraysize] = userinput3;
num++
}
}
// function main begins program exectuion
int main()
{
students.displayMessage();
students.getNumstudents();
students.getData();
students.sortData();
students.printData();
}