based on their ranking among their peers and OUTPUT informat

based on their ranking among their peers, and OUTPUT information as defined below. The program should eontain separate functions wherever redundancy appears; you M 3 User-Defined Functions in your program. Create a Program that will INPUT Employee Information from a ,calculate the BONUS UST have at least The INPUT information must include Employee Name (both First and Las), an Employee ID, their Home Address (Street, City State and Zip), their Home Phone/Personal Contact Number, their Work Location (you should have at least 3 different/possible locations), their Base Salary, and their Sales for the last 12 months. ALL information INPUT about each employee, except their Bonus and Total Salary, of course, will be obtained from a file which you will need to create. INPUT will be read into a STRUC which you will design. The program will calculate a 20% bonus based on their Total Sales for the year if they are the top selling employee, a 15% bonus if they are the #2 person and 10 % if they are the number 3 person. All other employees will receive a 5% bonus if their sales are greater than a specified \"minimum\" amount or NO bonus if they did not produce that \"minimum\" amount. The employees TOTAL SALARY is their Base Salary plus their BONUS. The OUTPUT will be PRINTED in increasing order by TOTAL SALARY for the vear Employees First and Last Name, Location, BONUS for the year should be printed. AIl OUTPUT MUST have appropriate headings. (Specifically, all information should be printed using the functionality contained in the preprocessor directive 1OMANIP, that is, output should be in tabular form with appropriate headings.) Lastly, you will print all Employee Contact Information separately. Again, First Name, Last Name, Employee ID, their Location and their Home Address and Home Phone and Ranking by Total Salary. EXTRA CREDIT: The program will calculate a 20% bonus based on their total sales for the year if they are the top selling employee FOR EACH LOCATION SEPARATELY and give, by LOCATION, a 15% bonus if they are the #2 person at their location and 10 % if they are the number 3 person. All other employees will receive a 5% bonus if their sales are greater than a specified “minimum\" amount For the Extra Credit, you will print all Employee Contact Information separately BY LOCATION. OUTPUT MUST INCLUDE: First Name, Last Name, Employee ID, their Location, Home Address and Home Phone, AND THEIR Ranking in order by BONUS for EACH LOCATION

Solution

#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <fstream>

using namespace std;


class Employee
{
public :
int employeeID;
private:
string firstName;
string lastName;
//int employeeID;
string street;
string city;
string state;
string zip;
float contactNumber;
string workLocation;
float baseSalary;
float sales[12];

bool operator<(const Employee & other) //(1)
{
return employeeID < other.employeeID;
}

public:
Employee();
~Employee(){}

void setFirstName(string firstNameLocal){
firstName = firstNameLocal;
}
void setLastName(string lastNameLocal){
lastName = lastNameLocal;
}
void setEmployeeID(int employeeIDLocal){
employeeID = employeeIDLocal;
}
void setStreet(string streetLocal){
street = streetLocal;
}
void setCity(string cityLocal) {
city = cityLocal;
}
void setState(string stateLocal) {
state = stateLocal;
}
void setZip(string zip) {
zip = zip;
}
void setContactNumber(float contactNumberLocal){
contactNumber = contactNumberLocal;
}
void setWorkLocation(float workLocationLocal){
workLocation = workLocationLocal;
}
void setBaseSalary(float baseSalaryLocal){
baseSalary = baseSalaryLocal;
}
void setSales(float salesL[]){
int i = 0;
for(; i < 12 ; i++){
sales[i] = salesL[i];
}
}
void printStockInfo();
};
//implementations
Employee::Employee()
{
baseSalary = 0.0;
}
//printing
void Employee:: printStockInfo()
{
cout << \"firstName : \" << firstName << \"\\t\";
cout << \"Last Name : \" << lastName << \"\\t\"<<endl;
cout << \" Salary \" << endl;
int idx = 0 ;
for(; idx < 12 ; idx++){
cout<< sales[idx] << endl;
}

}
bool compare(const Employee & l, const Employee & r) //(2)
{
return l.employeeID < r.employeeID;
}
std::vector<Employee> tokens;
int main()
{

std::ifstream file(\"Newfile.txt\");
std::string line = \"deepak rajdev 1 stree1 city1 state1 201301 12345678 newjersy 10000 100,200,100,300,202.5,300,400,200,100,300,400,500\";

// while(std::getline(file, line)) { // \'\ \' is the default delimiter
std::istringstream iss(line);
std::string token;
Employee *f1 = new Employee;
string firstName;
string lastName;
string employeeID;
string street;
string city;
string state;
string zip;
string contactNumber;
string workLocation;
string baseSalary;
string sales;
std::string::size_type sz;
getline (iss, firstName, \' \'); //read from in, store iso and table
getline (iss, lastName, \' \'); //getline will only use string
getline (iss, employeeID, \' \');
getline (iss, street, \' \');
getline (iss, city, \' \');
getline (iss, state, \' \');
getline (iss, zip, \' \');
getline (iss, contactNumber, \' \');
getline (iss, workLocation, \' \');
getline (iss, baseSalary, \' \');
getline (iss, sales, \' \');
// cout << firstName << lastName << sales << endl ;
f1->setFirstName(firstName);
f1->setLastName(lastName);
int tEmpID = std::atoi(employeeID.c_str());
f1->setEmployeeID(tEmpID);
float tBaseSalary = std::atof(baseSalary.c_str());
f1->setBaseSalary(tBaseSalary);
std::istringstream iss1(sales);
string token1;
int i = 0 ;
float salesLocal[12];
while (getline(iss1,token1, \',\'))
{
float salesTemp = std::atof(token1.c_str());
if( i < 12){
salesLocal[i] = salesTemp;
i++;
}
f1->setSales(salesLocal);
}
tokens.push_back(*f1);

// std::sort(tokens.begin(), tokens.end(), compare);//
// }
vector<Employee>::iterator it1;
for ( it1 = tokens.begin(); it1 != tokens.end(); ++it1 ) {
it1->printStockInfo();
}

return 0;
}


Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site