Hey guyz this is gonna be my last question (THANKS IN ADVANCE):
4. Display Data
Write a function to read and display the contents of names and marks. You then ask the user for a name and using the linear search return the index to the user. If -1 is returned then the name is not in the file. Otherwise write out the name and mark for that student.
Next, sort the arrays, write them out and then ask the user for a name to search for. This time use the binarySearch to return -1 or an index. Display the student’s name and mark if found.
Code:
void getNames(ifstream& inStream, string names[], int marks[], int numElts);
int linearSearch(const string names[], int numElts,string who);
int binarySearch(const string names[], int numElts,string who);
void selectionSort(string names[], int marks[],int numElts);
void displayData(const string names[], const int marks[], int numElts);
int main()
{
string names[NUM_NAMES];
int marks[NUM_NAMES];
ifstream inStream;
int index;
string searchWho;
AND YEA GUYZ I WAS MISSING THE FOLLLOWING INFO ON THE LAST 4 QUESTIONS I PUT UP:
File for names and marks:
Collins Bill 80
Smith Bart 75
Allen Jim 82
Griffin Jim 55
Stamey Marty 90
Rose Geri 78
Taylor Terri 56
Johnson Jill 77
Allison Jeff 45
Looney Joe 89
Wolfe Bill 63
James Jean 72
Weaver Jim 77
Pore Bob 91
Rutherford Greg 42
Javens Renee 74
Harrison Rose 58
Setzer Cathy 93
Pike Gordon 48
Holland Beth 79