F 79 Ce 6589 B 3 B 377 B 9 Ac 7
F 79 Ce 6589 B 3 B 377 B 9 Ac 7
F 79 Ce 6589 B 3 B 377 B 9 Ac 7
/*
Isaac Bernal
Fundamentals of Programming 2
Professor Lara
4/14/22
This program demostrates the use of linear search on a list of faculty members' first name, last
name, and I.D.
*/
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include "Faculty.h"
using namespace std;
//Function Prototypes
void welcome();
void SelectionSort(Faculty [], int);
int getData(Faculty[], const int );
void printData(Faculty[], int);
int main() {
const int SIZE = 4;
Faculty instructorArray[SIZE];//Class Array
ifstream inputfile;//to access files
int lcount = 0;
welcome();
SelectionSort(instructorArray, lcount);
printData(instructorArray, lcount);
return 0;
}
//Function Definitions
//***********************************************************
void welcome()
{
cout << "\t\t_-_Welcome To Faculty Member Sort_-_\n\n\tSorting By Last Name in Descending
Order...\n";
}
//***********************************************************
//To Receive the Faculty class array and sorts in descending order by last name
// Returns nothing
void SelectionSort(Faculty fArray[], int numbersSize)
{
int i;
int j;
int indexSmallest;
Faculty temp; // Temporary variable for swap
//***********************************************************
//Reads the text file and store in array
//returns the counter of total members of the array
int getData(Faculty arrayN[], const int SIZE)
{
istringstream inSS;//each members data is in a single line
ifstream inputfile;// to access txt file
inputfile.open("list.txt");
string lineString;
arrayN[counter].setID(iD);
inputfile.close();
return counter;
}
//***********************************************************
void printData(Faculty fArray[], int SIZE)
{
cout << "\n\nThe list is: \n\n";
for (int counter = 0; counter < SIZE; ++counter)
{
cout << (counter + 1) << ". " << fArray[counter].getLastName() << endl;
cout << (counter + 1) << ". " << fArray[counter].getFirstName() << "\n";
cout << (counter + 1) << ". " << fArray[counter].getID() << "\n\n";
}
}
//* --- This file is the IMPLEMENTATION FILE ---
#include <string>
using namespace std;
#include "Faculty.h"
void Faculty::setLastName(string l)
{
lastName = l;
}
void Faculty::setID(short i)
{
facultyID = i;
}
string Faculty::getFirstName()
{
return firstName;
}
string Faculty::getLastName()
{
return lastName;
}
short Faculty::getID()
{
return facultyID;
}
/*
--- This file is the SPECIFICATION FILE ---
*/
#include <string>
using namespace std;
#ifndef FACULTY_H
#define FACULTY_H
class Faculty
{
private:
string lastName;
string firstName;
short facultyID;
public:
//Prototypes
void setFirstName(string f);
void setLastName(string l);
void setID(short i);
string getFirstName();
string getLastName();
short getID();
};
#endif