Severity: Warning
Message: fopen(/home/solutionspile.com/public_html/system/sessions/ci_sessioni3d914rn3e5qp5id535ntiqjalrm9qe5): failed to open stream: No space left on device
Filename: drivers/Session_files_driver.php
Line Number: 176
Backtrace:
File: /home/solutionspile.com/public_html/index.php
Line: 367
Function: require_once
Severity: Warning
Message: session_start(): Failed to read session data: user (path: /home/solutionspile.com/public_html/system/sessions)
Filename: Session/Session.php
Line Number: 143
Backtrace:
File: /home/solutionspile.com/public_html/index.php
Line: 367
Function: require_once
*) ALL QUESTIONS ARE C++ related
*) Please refer to the reference for a better understanding
*) Main objective is to alter the main.cpp file and complete the code of the Sort Class to make the program run successful
*) Make file must be included in order to combine employee.txt, main.cpp together
*) Attach the screenshot of the running program at the end and it should resemble as attached output example
Output example
Reference only:( Main.cpp, employee.txt)
Main.cpp
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string.h>
using namespace std;
// class for employee
class Employee
{
public:
string type;
string SSN;
string lastName;
string firstName;
string department;
string role;
double salary;
// Default constructor
Employee ()
{
type = "";
SSN = "";
lastName = "";
firstName = "";
department = "";
role = "";
salary = 0;
}
// Initializer
void init(string t, string s, string l, string f, string d, string r, double s1)
{
type = t;
SSN = s;
lastName = l;
firstName = f;
department = d;
role = r;
salary = s1;
}
// Function to find the employee with the given SSN
static int findEmployee(Employee *employees, int size, string SSN)
{
for (int i = 0; i < size; i++)
{
if (employees[i].SSN == SSN)
{
return i;
}
}
return -1;
}
// Function to display the header of the table "Type SSN LastName FirstName Department Role Salary"
static void displayHeader()
{
cout << "-----------------------------------------------------------------------------------------------------------------" << endl;
cout << left << setw(10) << "Type" << setw(15) << "SSN" << setw(15) << "LastName" << setw(15) << "FirstName" << setw(15) << "Department" << setw(25) << "Role" << setw(15) << left << "Salary" << endl;
cout << "-----------------------------------------------------------------------------------------------------------------" << endl;
}
// Function to display the information of the employee
void display()
{
cout << left << setw(10) << type << setw(15) << SSN << setw(15) << lastName << setw(15) << firstName << setw(15) << department << setw(25) << role << setw(15) << left << setprecision(2) << fixed << salary << endl;
}
};
int main()
{
// Open file "explore.txt" in read mode
ifstream inFile;
inFile.open("employee.txt");
if (!inFile)
{
cout << "Unable to open file";
exit(1);
}
// Declare an array of Employee class
Employee *employees = new Employee[100];
// Declare variables
string Type, SSN, LastName, FirstName, Department, Role;
double Salary;
// Read the file and store the information in the array
int count = 0;
while (!inFile.eof())
{
inFile >> Type;
if (Type == "S")
{
inFile >> SSN >> LastName >> FirstName >> Department >> Role >> Salary;
employees[count].init(Type, SSN, LastName, FirstName, Department, Role, Salary);
count++;
}
else if (Type == "H")
{
inFile >> SSN >> LastName >> FirstName >> Department >> Role >> Salary;
employees[count].init(Type, SSN, LastName, FirstName, Department, Role, Salary);
count++;
}
}
// Display the header
Employee::displayHeader();
// Display the information of the salaried employees first and the hourly employees
for (int i = 0; i < count; i++)
{
if (employees[i].type == "S")
{
employees[i].display();
}
}
for (int i = 0; i < count; i++)
{
if (employees[i].type == "H")
{
employees[i].display();
}
}
// Ask user to enter an SSN and find the corresponding employee and display the information of that employee
cout << "Enter an SSN: ";
cin >> SSN;
for (int i = 0; i < count; i++)
{
if (SSN == employees[i].SSN)
{
employees[i].display();
}
}
// Close the file
inFile.close();
}
employee.txt
??????????????