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...
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...
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”...
In this Question using c++, you are to develop an employee management system using classes. You...
In this Question using c++, you are to develop an employee management system using classes. You need to develop two classes: Date and Employee. The Date class has the three attributes (int): month, day, and year. The class has the following member functions: • string getDate(void): returns a string with the date information (e.g, Mach 27, 2020). In addition to these, declare and implement proper constructors, a copy constructor, a destructor, and getters and setters for all data members. The...
C++ Modify this to use a separate Boolean member to keep track of whether the queue...
C++ Modify this to use a separate Boolean member to keep track of whether the queue is empty rather than require that one array position remain empty. #include <stdio.h> #include <stdlib.h> #include <limits.h> // A structure to represent a queue struct Queue { int front, rear, size; unsigned capacity; int* array; }; // function to create a queue of given capacity. // It initializes size of queue as 0 struct Queue* createQueue(unsigned capacity) { struct Queue* queue = (struct Queue*)...
Ava wants to use a database to keep track of the data recordsfor her insurance...
Ava wants to use a database to keep track of the data records for her insurance company and to enforce the following business policies/requirements: USE MS ACCESS TO CREATE A DATABASE & RELATIONASHIP-Every customer must be uniquely identified.-A customer can have many insurance policies.-Every insurance policy must be uniquely identified.-An insurance policy must belong to a valid customer.-Every customer must be served by a valid insurance agent (employee).-An insurance agent (employees) serves many customers.-Every insurance agent (employee) must be uniquely...
Q3) Design a class for saving data of employee, the class should have multiple constructors (constructor...
Q3) Design a class for saving data of employee, the class should have multiple constructors (constructor overloading) for initializing objects with different parameters. The employee class should have different functions for saving and updating bio-data, educational background, and current status like experience, Salary, position & travel history. The employee class should have a function which asks user what do he likes to see about employee (.i.e., Bio-data, current status....) and only show the respective data. Create two objects of interns...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT