Question

In: Computer Science

Using c++ Design a system to keep track of employee data. The system should keep track...

Using c++ Design a system to keep track of employee data. The system should keep track of an employee’s name, ID number and hourly pay rate in a class called Employee.

You may also store any additional data you may need, (hint: you need something extra). This data is stored in a file (user selectable) with the id number, hourly pay rate, and the employee’s full name (example):

17 5.25 Daniel Katz
18 6.75 John F. Jones

Start your main method by asking the user the name of the file to open.

Additionally we would like to be able to print payroll information from data in a different file. The data is the employee’s id number and a number of hours that they worked (example):

17 40
18 20
18 20

As you see we can have the same number listed twice in which case that person should be paid the sum of the numbers (John Jones did 40 hours work, but it’s listed as 20+20).

You should start by reading in the first file and storing the data as objects in a linked list. You will need to create the linked list class and the Employee data class.

You may choose to use the Linked List class we created, or you may opt to create your own doubly linked list class. Do not use STL linked class.The Linked list could be templated or not, it’s up to you, however templating it would allow it to be used for other projects, so it might be a good idea.

Once you have read in the information from the first file, read in the second file. Ultimately we would like to print payroll information based on the hourly wage from the first file multiplied by the number of times an employee worked in the second file. How you do this is entirely up to you.

The output must be in sorted (descending; so the person who gets paid most prints first) order in the form of:

*********Payroll Information********
Daniel Katz, $210
John F. Jones, $270
*********End payroll**************

The basic flow of the program is as follows:

  • Ask the user for the name of a file to open.
  • Read in the employee information and to the list.
  • Ask the user for the name of a file to open.
  • Read in the payroll information
  • Output the Payroll Information

Solutions

Expert Solution

#include<iostream>
#include<cstdlib>
#include<fstream>
#include<cstring>
using namespace std;
class Employee
{
string name[500];
int id[500];
float payrate[500];
float payroll[500];
int count;
public:
Employee()
{
count=0;
}
void readData(ifstream &f1,ifstream &f2)
{

string str;
while(getline(f1,str))
{
int i=1;
string s;
s=str[i-1];
while(str[i]!=' ')
{
s=s+str[i];i++;
}
id[count]=atoi(s.c_str());
i=i+2;
string s1;
s1=str[i-1];
while(str[i]!=' ')
{
s1=s1+str[i];
i++;
}
payrate[count]=atof(s1.c_str());
i=i+2;
name[count]=str[i-1];
while(str[i]!='\0')
{
name[count]=name[count]+str[i];
i++;
}
//char x;
payroll[count]=0;
count++;
}
int tid,temp;
while(!f2.eof())
{
f2>>tid>>temp;
for(int i=0;i<count;i++)
{
if(tid==id[i])
{
payroll[i]=payroll[i]+temp*payrate[i];
}
}
}
}
void printInfo()
{
cout<<endl;
for(int i=0;i<count;i++)
{
cout<<name[i]<<","<<payroll[i]<<endl;
}
}
};
int main()
{
Employee obj;
char fname[100];
cout<<"Enter file name:";
ifstream f1;
cin>>fname;
f1.open(fname);
if(!f1)
{
cout<<"File opening error";
return 0;
}
cout<<"Enter file name:";
ifstream f2;
cin>>fname;
f2.open(fname);
if(!f2)
{
cout<<"File opening error";
return 0;
}
obj.readData(f1,f2);
obj.printInfo();
return 0;
}

Related Solutions

Design a class named Employee. The class should keep the following information in fields: ·         Employee...
Design a class named Employee. The class should keep the following information in fields: ·         Employee name ·         Employee number in the format XXX–L, where each X is a digit within the range 0–9 and the L is a letter within the range A–M. ·         Hire date Write one or more constructors and the appropriate accessor and mutator methods for the class. Next, write a class named ProductionWorker that inherits from the Employee class. The ProductionWorker class should have fields...
Design a class named Employee. The class should keep the following information in fields: ·         Employee...
Design a class named Employee. The class should keep the following information in fields: ·         Employee name ·         Employee number in the format XXX–L, where each X is a digit within the range 0–9 and the L is a letter within the range A–M. ·         Hire date Write one or more constructors and the appropriate accessor and mutator methods for the class. Next, write a class named ProductionWorker that inherits from the Employee class. The ProductionWorker class should have fields...
C# The Zookeepers need a system to keep track of all their animals. They need to...
C# The Zookeepers need a system to keep track of all their animals. They need to be able to enter all their animals into the system in a way that allows them to identify and locate them. This requires identifying them by species, age and one characteristic unique to their species. There are three cages and the user must input information about the animal in each one. After accepting input for all three cages, the program should output the contents...
C# The Zookeepers need a system to keep track of all their animals. They need to...
C# The Zookeepers need a system to keep track of all their animals. They need to be able to enter all their animals into the system in a way that allows them to identify and locate them. This requires identifying them by species, age and one characteristic unique to their species. There are three cages and the user must input information about the animal in each one. After accepting input for all three cages, the program should output the contents...
You will design a program to keep track of a restaurants waitlist using a queue implemented...
You will design a program to keep track of a restaurants waitlist using a queue implemented with a linked list. Make sure to read pages 1215-1217 and 1227-1251 1. Create a class named waitList that can store a name and number of guests. Use constructors to automatically initialize the member variables. 2. Add the following operations to your program: a. Return the first person in the queue b. Return the last person in the queue c. Add a person to...
Design a database through the EER diagram to keep track of the teams and games of...
Design a database through the EER diagram to keep track of the teams and games of a sport league. Assume that the following requirements are collected (the English description of cardinal ration and partial/complete participate is NOT required, but you still need to provide the total/partial and cardino ration in your EER diagram) : The database has a collection of TEAM. Each Team has a unique name, players, and owner. The database also keeps the records of PLAYERS. Each player...
Design and implement a class called circle_location to keep track of the position of a single...
Design and implement a class called circle_location to keep track of the position of a single point that travels around a circle. An object of this class records the position of the point as an angle, measured in a clockwise direction from the top of the circle. Include these public member functions: • A default constructor to place the point at the top of the circle. • Another constructor to place the point at a specified position. • A function...
In the design of communication links we must always keep track of the power needed to...
In the design of communication links we must always keep track of the power needed to represent the signals, the effects of the noise and the bandwidth needed. In a post answer the following : What do you think should be the comparison of signal power vs. noise power? What do you think will be the most effective method to increase the distance in a communications link? What do you think will be the most effective method to increase the...
You are tasked to design an application to keep track of sales for your company. Sales...
You are tasked to design an application to keep track of sales for your company. Sales should be tracked for two types of accounts: supplies and services. Complete the following:     Create a UML class diagram for the Account inheritance hierarchy. Your subclasses should be Supplies and Services.     All sales accounts will have an account ID (accountId).     You will need attributes to keep track of the number of hours (numberOfHours) and rate per hour of services provided (ratePerHour)....
Write a c++ program for the Sales Department to keep track of the monthly sales of...
Write a c++ program for the Sales Department to keep track of the monthly sales of its salespersons. The program shall perform the following tasks: Create a base class “Employees” with a protected variable “phone_no” Create a derived class “Sales” from the base class “Employees” with two public variables “emp_no” and “emp_name” Create a second level of derived class “Salesperson” from the derived class “Sales” with two public variables “location” and “monthly_sales” Create a function “employee_details” under the class “Salesperson”...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT