Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In the current assignment you are to write a C program (or modify the previous o

ID: 3827080 • Letter: I

Question

    
   
 In the current assignment you are to write a C program (or modify the previous one) to compute payroll for the XYZ MANUFACTURING COMPANY. The input data has been changed and is follows: bill mcdaniel m 2929 51 sa 727.67 harry smith m 1111 68 sa 634.34 fred thompson m 0191 22 sa 530.41 andy baxter s 9383 17 sa 250.00 charles johnson m 6638 35 sa 260.50 mary ann munter m 0011 40 sa 420.00 herb hocutt m 6655 45 hr 22.00 35 terry smith s 3230 67 hr 7.50 45 david bledsoe s 0027 21 hr 37.50 40 patty roesner s 2828 20 hr 13.50 35 terrance appleby m 0651 25 sl 310.00 42 joseph mccomb m 4559 36 sl 320.00 35 todd tussel m 6448 43 sl 3280.00 40 bill ryan s 8334 54 sl 1420.00 45 The columns are as follows: first name last name marital status employee number age category amount hours There are 3 categories for payments: sa (salary), hr (hourly) and sl (sliding scale). If the category is sa then the gross_pay is amount. If the category is hr then the gross_pay is amount*hours. If the category is sl then the gross_pay is calculated as follows: if the hours is <= 40 then the gross_pay is the amount else rate per hour = amount / hours if (rate per hour < 5.25) then rate per hour = 5.25 gross pay = rate_per_hour * hours + (hours - 40) * rate_per_hour / 2; Federal income tax is computed according to the following table: joint 0 42350 102300 155950 278450 single 0 25350 61400 128100 278450 2000 15.0 28.0 31.0 36.0 39.0 2001 10.0 27.5 30.5 35.5 39.1 2002 10.0 27.0 30.0 35.0 38.6 2003 10.0 27.0 30.0 35.0 38.6 2004 10.0 26.0 29.0 34.0 37.6 2005 10.0 26.0 29.0 34.0 37.6 2006 10.0 25.0 28.0 33.0 35.0 Example: For the year 2001, if a married person makes a yearly income < 42350, that individual would pay 10% on that income. For the year 2001, if a single person makes a yearly income >= 25350 and < 61400, that individual would pay 27.5 on that income. You will have to find a routine that returns the current year. Computation of deductions is as follows: fica = gross * .07652; sttax = gross * .07; net = gross - fit - fica - sttax; Sample Output: NAME GROSS FED SOC STATE NET TAX SEC TAX bill mcdaniel 727.67 72.77 55.68 50.94 548.28 harry smith 634.34 63.43 48.54 44.40 477.96 fred thompson 530.41 53.04 40.59 37.13 399.65 andy baxter 250.00 25.00 19.13 17.50 188.37 charles johnson 260.50 26.05 19.93 18.24 196.28 mary ann munter 420.00 42.00 32.14 29.40 316.46 herb hocutt 770.00 77.00 58.92 53.90 580.18 terry smith 337.50 33.75 25.83 23.62 254.30 david bledsoe 1500.00 457.50 114.78 105.00 822.72 patty roesner 472.50 47.25 36.16 33.08 356.02 terrance appleby 317.38 31.74 24.29 22.22 239.14 joseph mccomb 320.00 32.00 24.49 22.40 241.11 todd tussel 3280.00 1164.40 250.99 229.60 1635.01 bill ryan 1498.89 457.16 114.69 104.92 822.11 You will be graded on accuracy, and programming style. Divide the program up into separate functions both for debugging and for clarity. There should be functions for computing gross_pay and for computing fit. You may include more functions if you like.  

Explanation / Answer

#include<iostream>
#include<math.h>
#include<cstdlib>
#include<string>
using namespace std;
class Person
{
private :   
string FirstName;   
string LastName;   
int PersonalID ;
double Salary ;
double WorkingHours ;
double CostPerHour ;
  
public :
  
void set_FieldName();
void get_FieldName();
void gett_FieldName();
void set_PersonalID();
void set_Name();
void LastNamesortList();
void in_FirstName();
void in_FamilyName();
void in_Workinghour();
void in_Costperhour();
};
  
class HRM
{
private:   
Person e[100] ;
Person temp[100];
public :
  
void AddPerson();
void DeletePerson();
void SearchPerson();
void UpdatePerson();
void ReportList();

};
int n=0,i=0,x=8248001,y[100];
bool flag=0;
int z[100];
string h[100];
double sal[100];
int check=0;
void ::HRM::AddPerson() {

int x;
char redo;

do
{
n++;
e[i].set_FieldName();
i++;
  
cout<<" The employee with the following information has been added to the system:"<<endl;
cout<<" First Name Last Name Personal ID Salary per year (Euros)";
cout<<" -------------- -------------- ------------ -------------------------"<<endl;
//cout<<"naaaaaaaaaaaam"<< n<<endl;
for(int i=0; i<n; i++){
e[i].get_FieldName();
}


cout<<"do u wont to add another employee"<<endl;
cin>>redo;
}
while((redo=='y'||redo=='Y'));
  
}
void HRM::DeletePerson() {
int empId;
bool lol;
char redo1,redo2;
lol =false;
lebel:
cout << "ID of employee to remove: ";
  
while(!(cin>>empId)) //Reciving vaiables from input : is it no/character ?
{
cout << "Please enter a number! Try again: ";
cin.clear ();   
cin.ignore (1000, ' ');}

for ( i = 0; i < n; ++i) {

  
if (y[i]==empId) {   
e[i]=e[i+1];
lol=true;
e[i].set_Name();
cin>>redo2;
if(redo2=='Y'||redo2=='y'){
int a;
a=n;   
  
cout<<" The employee with the following information has been added to the system:"<<endl;
cout<<" First Name Last Name Personal ID Salary per year (Euros)";
cout<<" -------------- -------------- ------------ -------------------------"<<endl;
for(int i=0; i<a; i++){

e[i].get_FieldName();
cout<<"hahahahah="<<n<<endl;
a--;
n=a;
n++;
}
  
cout <<endl;   
}

}

  
if (lol==false) {
cout<<"Sorry, there is not any employee with requested personal number."
<<" Do you want to repeat delete by entering the new personal number (y/n)?:";
cin>>redo1;
if(redo1=='Y'||redo1=='y'){
goto lebel;
cout<<endl<<endl;
}
}
}
// Definition of the UpdatePerson() method of the Company class
// This method will modify an attribute of the employee in
// the Company class instance. The employee and attribute should be
// ones of the user's own choosing.
void HRM::UpdatePerson(){

int empId;
char redo1,redo2;
lebel:
cout << "ID of employee to modify data: ";
while(!(cin>>empId))
{
cout << "Please enter a number! Try again: ";
cin.clear ();   
cin.ignore (1000, ' ');
}   
  
int flag1=0;
for (int i = 0; i < n; ++i) {
  
if (y[i]!=empId) {
flag1++;

}
}
if (flag1==n){
  
// cout<<" not matching="<< y[i];
cout<<"Sorry, there is not any employee with requested personal number. Do you want to repeat delete by entering the new personal number (y/n)?:";
cin>>redo1;
if(redo1=='Y'||redo1=='y'){
goto lebel;
}
} */   

cout <<endl;   
lebel1:
  
for (int i = 0; i < n; ++i) {

  
if (y[i]==empId) {

cout<<"matching="<< y[i];

flag=true;
int choice = 0;
char redo;

do {
cout << endl << endl;
cout << "Please enter the related number of field which you would like to update" << endl;
cout <<"1. First name" << endl;
cout << "2. Family name" << endl;
cout << "3. Working hours per week" << endl;
cout << "4. Payment for one hour" << endl;
cout << std::endl;

cin >> choice;
if (choice == 1) {
cout << " First name: ";
e[i].in_FirstName();
}
else if (choice == 2) {
cout << " Family name: ";
e[i].in_FamilyName();
}
else if (choice == 3) {
cout << " Working hours per week: ";
e[i].in_Workinghour();
}
else if (choice == 4) {
cout << " Payment for one hour: ";
e[i].in_Costperhour();
}
cout<<"Do you want to update another field (Y/N)=";
cin>>redo;
} while (redo=='y'||redo=='Y');
}
}
int a;
a=n;
cout<<" The employee with the following information has been added to the system:"<<endl;
cout<<" First Name Last Name Personal ID Salary per year (Euros)";
cout<<" -------------- -------------- ------------ -------------------------"<<endl;
for(int i=0; i<a; i++){
e[i].get_FieldName();
  
cout<<"hahahahah="<<n<<endl;

}
}
void ::Person::in_FirstName()
{
cin>>FirstName ;
}
void::Person::in_FamilyName()
{
cin>>LastName;
}
void::Person::in_Workinghour()
{
cin>>WorkingHours;
Salary=WorkingHours*CostPerHour*52;
}
void::Person::in_Costperhour()
{
cin>>CostPerHour;
Salary=WorkingHours*CostPerHour*52;
}
void HRM::SearchPerson(){
int c;
char redo1;
string familyname;
double min,max;
do{
cout<<"Search is based on two different fields (1.family name, 2.Salary), please enter your choice?="<<endl;
//cin>>c;
while(!(cin>>c))
{
cout << "Please enter a number! Try again: ";
cin.clear ();   
cin.ignore (1000, ' ');
}
  
  
if(c==2)
  
{
cout<<"Please define your search range for salary of employees ."<<endl;
cout<<"What is minimum salary for search (S_min)?="<<endl;
while(!(cin>>min))
{
cout << "Please enter a number! Try again: ";
cin.clear ();   
cin.ignore (1000, ' ');
}
cout<<"What is maximum salary for search (S_max)?="<<endl;
//cin>>max;
while(!(cin>>max))
{
cout << "Please enter a number! Try again: ";
cin.clear ();   
cin.ignore (1000, ' ');

}
int a;
a=n;
cout<<" The employee with the following information has been added to the system:"<<endl;
cout<<" First Name Last Name Personal ID Salary per year (Euros)";
cout<<" -------------- -------------- ------------ ------------------"<<endl;
for(int i=0; i<n; i++) {
  
  
if (z[i]>min && z[i]<max) {

cout<<"naaaaaaaaaaaam"<< n<<endl;   
e[i].gett_FieldName();   
cout<<"matching="<< z[i];   
}
}


}

else if(c==1)
{
cout<<"Please enter the family name of employee?"<<endl;
cin>>familyname;
cout<<" The employee with the following information has been added to the system:"<<endl;
cout<<" First Name Last Name Personal ID Salary per year (Euros)";
cout<<" -------------- -------------- ------------ --------------------"<<endl;
for(int i=0; i<n; i++) {

  
if (h[i]==familyname) {
  
cout<<"naaaaaaaaaaaam"<< n<<endl;   
e[i].gett_FieldName();   
cout<<"matching="<< z[i];   
}
}
}

cout<<" Do you want to Search any other field (y/n)? "<<endl;
cin>>redo1;
}while(redo1=='y'||redo1=='Y');


}
void ::Person::LastNamesortList() {
int temp2;
char temp,temp1;
}
  
void::Person ::set_Name(){
cout<<"Do you really want to delete employee"<<FirstName<<" "<< LastName<< "(y/n)?:"; //PersonalID=y[i];
}   
  
int k=0;
void::Person ::set_FieldName(){
PersonalID=x;
x++;
cout<<n;
cout<<"First Name=";
while(!(cin>>FirstName))
{
cout << "Please enter a string! Try again: ";
cin.clear ();   
cin.ignore (1000, ' ');
}
cout<<"Last Name=";
  
while(!(cin>>LastName))
{
cout << "Please enter a string! Try again: ";
cin.clear ();   
cin.ignore (1000, ' ');
}
cout<<"How many hours a week is his/her work? =";
;
while(!(cin>>WorkingHours))
{
cout << "Please enter a number! Try again: ";
cin.clear ();   
cin.ignore (1000, ' ');
}
cout<<"How much per hour is his/her salary? =";
while(!(cin>>CostPerHour))
{
cout << "Please enter a number! Try again: ";
cin.clear ();   
cin.ignore (1000, ' '); // Skip to next newline or 1000 chars,

}
Salary=WorkingHours*CostPerHour*52;
z[i]= Salary;
sal[i]=Salary;
h[i]=LastName;
y[k]=PersonalID;
k++;
}
void::Person ::get_FieldName(){
cout<<FirstName<<" "<<LastName<<" "<<PersonalID<<" "<<Salary<<" "<<endl;

void::Person ::gett_FieldName(){
cout<<FirstName<<" "<<LastName<<" "<<PersonalID<<" "<<Salary<<" "<<endl;
}
int main()
{
HRM info ;
  
int c;
char operation,ch;
cout<< "Welcome to the program 2.1 written by Your Name"<<endl;
cout<<"********************"<<endl;
cout<<endl<<endl<<endl;
do
{
cout<<"Welcome to Human Resource Management (HRM) Software of Company XYZ.";
cout<<"To do specific task please choose one of the following commands."<<endl<<endl<<endl;
cout<<" 1. Add new employee"<<endl;
cout<<" 2. Delete employee information"<<endl;
cout<<" 3. Update employee information"<<endl;
cout<<" 4. Make reports based on specific field"<<endl;
cout<<" 5. Search employee"<<endl;
cout<<" 6. Quit"<<endl<<endl;
while(!(cin>>c)) {
cout << "Please enter a number! Try again: ";
cin.clear ();   
cin.ignore (1000, ' ');
}
switch(c)
{
case 1:
cout<<" Enter the information of the new employee"<<endl;
info.AddPerson();
break;
case 2:
info.DeletePerson();
break;
case 3:
cout<<" Enter an item to deletion";
info.UpdatePerson();
break;
case 4:
cout<<" Enter an element to search";
info.ReportList();
break;
case 5:
info.SearchPerson();
break;
default :
cout<<" Invalid option try again";

}
cout<<" do u want to continue";
cin>>ch;
}
while(ch=='y'||ch=='Y');
system("pause");
return 0;