TAKEN FROM FILE PLEASE I NEED THIS DONE IN HOUR C++ Using this ---- write the functions Abel Herrera 402879 32 Accounting 783.97 4 Eddie Lauren 103938 26 Marketing 9728.23 2 Monica Strauss 110030 29 IT 2368.91 4 Claire Matteo 938928 30 Marketing 1922.12 5 Farida Ahmed 288489 22 IT 88201.67 3 David Masterson 183920 43 Accounting 180.48 1 Chloe Gignac 991229 35 Publishing 912.34 3 William Tucker 410293 51 Accounting 140.19 6 Daniela Moreira 882927 39 Publishing 3192.34 5 Birgit Prinz 273935 32 Acquisitions 123979.99 4 Trish Seaman 393001 48 Marketing 2990.23 6 Tatsuya Shiba 291993 19 Acquisitions 54497.56 3 Rayna Cranel 847392 27 IT 129.11 5 Luiz Sastre 198339 44 Accounting 521.78 6 Dimitri Petrov 792024 61 HR 1233.68 7 Nathan Cook 310233 54 Marketing 89.40 5 Philip Alvida 822974 59 HR 788.19 6 Ryner Lute 902217 18 Acquisitions 776322.98 3 Bruce Wayne 102837 36 IT 999999.39 6 Minerva McGonagall 404955 71 Publishing 450228.34 9
A.A function to display the full details of every employee using
the output function
B.A function that displays the first, last name, salary, and
numbers of years worked of the oldest employee on the list
C.A function that displays the first, last name, and department of
the lowest earner in the company
D.A function that takes in as a paremeter an integer representing
the minimum age required to qualify for a special bonus, and
displays the first, last name, age and department of all employees
eligible for the bonus.
E.A function that returns the name of the department that has the
highest total earning
Given below is the code for the question.
Please do rate the answer if it was helpful. Thank you
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
using namespace std;
ifstream infile;
struct employeeType
{
string fname;
string lname;
int age;
string department;
string SSN;
double salary;
int yearsWorked;
};
void input(employeeType employees[], int &size);
void output(employeeType employee);
void displayAll(employeeType employees[], int size);
void displayOldest(employeeType employees[], int size);
void displayLowest(employeeType employees[], int size);
void displayBonusEmp(employeeType employees[],int size, int
minAge);
double getDepartmentEarning(employeeType employees[],int size,
string department);
string getHighestDept(employeeType employees[],int size);
int main()
{
employeeType employees[20];
int size;
cout<<left;
cout<<fixed<<showpoint<<setprecision(2);
int choice = 0;
input(employees, size);
while(choice != 6)
{
cout << "1. Display all employees" << endl;
cout << "2. Display oldest employee" << endl;
cout << "3. Display lowest earner" << endl;
cout << "4. Display employees eligible for bonus" <<
endl;
cout << "5. Display highest earning department" <<
endl;
cout << "6. Quit" << endl;
cout << "Enter your choice: ";
cin >> choice;
switch(choice)
{
case 1:
displayAll(employees, size);
break;
case 2:
displayOldest(employees, size);
break;
case 3:
displayLowest(employees, size);
break;
case 4:
displayBonusEmp(employees, size, 47);
break;
case 5:
cout << "The department earning highest is " <<
getHighestDept(employees, size) << endl;
break;
case 6:
break;
default:
cout << "Invalid choice!" << endl;
}
}
system ("pause");
return 0;
}
void input(employeeType employees[], int &size)
{
infile.open("Question1_Final.txt");
int i;
for(i = 0; i < 20; i++)
{
infile>>employees[i].fname>>employees[i].lname>>employees[i].SSN>>employees[i].age>>employees[i].department
>>employees[i].salary>>employees[i].yearsWorked;
}
size = i;
}
void output(employeeType employee)
{
cout<<setw(15)<<employee.fname<<setw(15)<<employee.lname<<setw(15)<<employee.SSN<<setw(8)<<employee.age
<<setw(15)<<employee.department<<setw(10)<<employee.salary<<"
"<<employee.yearsWorked<<endl;
}
void displayAll(employeeType employees[], int size)
{
cout << "List of all employees" << endl;
for(int i = 0; i < size; i++)
output(employees[i]);
cout << endl << endl;
}
void displayOldest(employeeType employees[], int size)
{
int maxWorked = employees[0].yearsWorked;
for(int i = 1; i < size; i++)
{
if(employees[i].yearsWorked > maxWorked)
maxWorked = employees[i].yearsWorked;
}
//print oldest employees
cout << "The oldest employees " << endl;
for(int i = 0; i < size; i++)
{
if(employees[i].yearsWorked == maxWorked)
{
cout<<setw(15)<<employees[i].fname<<setw(15)<<employees[i].lname
<<setw(10)<<employees[i].salary<<"
"<<employees[i].yearsWorked<<endl;
}
}
cout << endl << endl;
}
void displayLowest(employeeType employees[], int size)
{
double minSalary = employees[0].salary;
for(int i = 1; i < size; i++)
{
if(employees[i].salary < minSalary)
minSalary = employees[i].salary;
}
//print oldest employees
cout << "The lowest earning employees " <<
endl;
for(int i = 0; i < size; i++)
{
if(employees[i].salary == minSalary)
{
cout<<setw(15)<<employees[i].fname<<setw(15)<<employees[i].lname
<<setw(15) << employees[i].department
<<setw(10)<<employees[i].salary<<endl;
}
}
cout << endl << endl;
}
void displayBonusEmp(employeeType employees[],int size, int
minAge)
{
cout << "Employees eligible for bonus (minimum age " <<
minAge << ")" << endl;
for(int i = 0; i < size; i++)
{
if(employees[i].age >= minAge)
{
cout<<setw(15)<<employees[i].fname<<setw(15)<<employees[i].lname
<<setw(10) << employees[i].age
<<setw(15) << employees[i].department <<endl;
}
}
cout << endl << endl;
}
double getDepartmentEarning(employeeType employees[],int size,
string department)
{
double total = 0;
for(int i = 0; i < size; i++)
{
if(employees[i].department == department)
total += employees[i].salary;
}
return total;
}
string getHighestDept(employeeType employees[],int size)
{
string maxDept = "";
double maxEarnings = 0;
for(int i = 0; i < size; i++)
{
if(employees[i].department != maxDept)
{
double deptEarnings = getDepartmentEarning(employees, size,
employees[i].department);
if(deptEarnings > maxEarnings)
{
maxDept = employees[i].department;
maxEarnings = deptEarnings;
}
}
}
return maxDept;
}
output
====
1. Display all employees
2. Display oldest employee
3. Display lowest earner
4. Display employees eligible for bonus
5. Display highest earning department
6. Quit
Enter your choice: 1
List of all employees
Abel Herrera 402879 32 Accounting 783.97 4
Eddie Lauren 103938 26 Marketing 9728.23 2
Monica Strauss 110030 29 IT 2368.91 4
Claire Matteo 938928 30 Marketing 1922.12 5
Farida Ahmed 288489 22 IT 88201.67 3
David Masterson 183920 43 Accounting 180.48 1
Chloe Gignac 991229 35 Publishing 912.34 3
William Tucker 410293 51 Accounting 140.19 6
Daniela Moreira 882927 39 Publishing 3192.34 5
Birgit Prinz 273935 32 Acquisitions 123979.99 4
Trish Seaman 393001 48 Marketing 2990.23 6
Tatsuya Shiba 291993 19 Acquisitions 54497.56 3
Rayna Cranel 847392 27 IT 129.11 5
Luiz Sastre 198339 44 Accounting 521.78 6
Dimitri Petrov 792024 61 HR 1233.68 7
Nathan Cook 310233 54 Marketing 89.40 5
Philip Alvida 822974 59 HR 788.19 6
Ryner Lute 902217 18 Acquisitions 776322.98 3
Bruce Wayne 102837 36 IT 999999.39 6
Minerva McGonagall 404955 71 Publishing 450228.34 9
1. Display all employees
2. Display oldest employee
3. Display lowest earner
4. Display employees eligible for bonus
5. Display highest earning department
6. Quit
Enter your choice: 2
The oldest employees
Minerva McGonagall 450228.34 9
1. Display all employees
2. Display oldest employee
3. Display lowest earner
4. Display employees eligible for bonus
5. Display highest earning department
6. Quit
Enter your choice: 3
The lowest earning employees
Nathan Cook Marketing 89.40
1. Display all employees
2. Display oldest employee
3. Display lowest earner
4. Display employees eligible for bonus
5. Display highest earning department
6. Quit
Enter your choice: 4
Employees eligible for bonus (minimum age 47)
William Tucker 51 Accounting
Trish Seaman 48 Marketing
Dimitri Petrov 61 HR
Nathan Cook 54 Marketing
Philip Alvida 59 HR
Minerva McGonagall 71 Publishing
1. Display all employees
2. Display oldest employee
3. Display lowest earner
4. Display employees eligible for bonus
5. Display highest earning department
6. Quit
Enter your choice: 5
The department earning highest is IT
TAKEN FROM FILE PLEASE I NEED THIS DONE IN HOUR C++ Using this ---- write the...
Please write in C++ MEMO To: The Programming Staff From The Boss I need a program that will help me figure out who gets what for this year’s annual bonuses. Here are the conditions: Every employee gets a basic bonus of $1000. All the employees in department 2 get an additional $1000 bonus (above the basic bonus) unless they have more than five dependents. Any employee with more than five dependents gets a $5000 bonus. And no – you can’t...
Please help me write in C++ language for Xcode. Thank you. In this lab you are going to write a time card processor program. Your program will read in a file called salary.txt. This file will include a department name at the top and then a list of names (string) with a set of hours following them. The file I test with could have a different number of employees and a different number of hours. There can be more than...
Rework this project to include a class. As explained in class, your project should have its functionalities moved to a class, and then create each course as an object to a class that inherits all the different functionalities of the class. You createclass function should be used as a constructor that takes in the name of the file containing the student list. (This way different objects are created with different class list files.) Here is the code I need you...