Payroll Reader

Payroll Project

Payroll

Payroll

a payroll program in c++
Program outline

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 

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. (Note: if you cannot get either working, you can use the STL list class but 20% will be deducted). 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, $270 

John F. Jones, $210 

*********End payroll************** 

				
					#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <time.h>

using namespace std;

void printArray(vector<int> min_max);
void findMinMax(vector<int> starting, int &min, int &max);

int main(){
    int array[] = {6,3,4,5,7,8,1};
    int len = sizeof(array)/sizeof(array[0]);
    int min, max;

    vector<int> starting;
    for(int i = 0; i < len; i++){
        starting.push_back(array[i]);
    }
    vector<int> min_max;
    min = starting[0];
    max = starting[0];
    
    //min_max = 
    findMinMax(starting, min, max);
    min_max.push_back(min);
    min_max.push_back(max);

    cout << "Final Min: " << min << endl;
    cout << "Final Max: " << max << endl;
    printArray(min_max);
}

void findMinMax(vector<int> starting, int &min, int &max){
    vector<int> v;
    if(starting.size() == 1){
        if(starting[0] < min){
            min = starting[0];
        }
        if(starting[0] > max){
            max = starting[0];
        }
    }
    else if(starting.size() == 2){
        if(starting[0] < starting[1]){
            if(starting[0] < min){
                min = starting[0];
            }
            if(starting[1] > max){
                max = starting[1];
            }
        }
        else{
            if(starting[1] < min){
                min = starting[1];
            }
            if(starting[0] > max){
                max = starting[0];
            }
        }
    }
    else{
        vector<int> v1, v2;
        for(int i = 0; i < starting.size() / 2; i++){
            v1.push_back(starting[i]);
        }
        if(starting.size() % 2 == 0){
            for(int i = starting.size() / 2; i < starting.size(); i++){
                v2.push_back(starting[i]);
            }
        }
        else{
            for(int i = starting.size() / 2; i < starting.size(); i++){
                v2.push_back(starting[i]);
            }
        }
        findMinMax(v1, min, max);
        findMinMax(v2, min, max);
    }
}

void printArray(vector<int> arr){
    for(int i = 0; i < arr.size(); i++){
        cout << arr[i];
        if(i < arr.size() - 1){
            cout << ", ";
        }
    }
}

				
			
Comments are closed.