Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You should not - include header with assignment description and your information at the beginning of the main function file, it is OPTIONAL - include

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

You should not - include header with assignment description and your information at the beginning of the main function file, it is OPTIONAL - include any comments, it is OPTIONAL - use global variables - use string streams You should - include your name at the beginning of CS215Lab_Midterm.cpp file: / / Student: John Smith - pass in vector by address(reference) to mutator helper functions - pass in vector by copy(value) to accessor helper functions Solve the following problem Write a payroll program that would allow user to compute weekly gross pay salary of hourly based employee and print employees with highest and lowest salaries. Use object-oriented programming approach. To implement this program, you will create three files: - employee.h - employee.cpp - CS215Lab_Midterm.cpp To represent an employee record, create a class Employee. 1. CLASS EMPLOYEE - copy class Employee interface from Figurel by typing it in employee.h file - then. write function definitions in emplovee.cDp file Figure1. Employee Interface (ATTENTION: you cannot modify this code) class Employee public: Employee(string name, double salary); double getSalary() const; void print() const; private: string name; double salary; Private variables of class Employee: - variable name will be used to store full name of an employee formatted as follows: "Last_name, First_name" (ex: "Waters, Dario") - variable salary will be used to store salary calculated in the main function (See Case 1 and Case 2 in description of read_file function below) 2. HELPER FUNCTIONS You will implement three helper functions in CS215Lab_Midterm.cpp. Vector of Employees must be declared local to the main and be passed to helper functions either by reference (to mutator functions) or by value (to accessor functions). void read_file(/* pass in vector of employees by address or copy /) This function is going to read Employee.txt file from Figure2. Text file must be downloaded from canvas and saved in the same folder as CS215Lab_Midterm.cpp within your Project folder. Figure2. employees.txt Dario Waters 408.25 Jerry Hebert 4412.10 Trevor Hill 45.58 .25 Tessa Berger 4012.10 Miles Oneal 2014.75 Mariah Garner 648.25 ByronLopez36NathalyBooneHelenaHughesTrevonDavenportAiyanaGillChaimGallagherParisCabreraMelanyCraigAlexandraBerryHallieElyseRandyForsterLawsonSnowAlysonHawkinsElyseSmith12.10404035.5214071.5404040644038.5408.2514.758.2512.108.258.2514.7514.7512.108.2514.7514.7514.75 Design for read file function: 1) open file and check if it can be opened, only if the file can be opened, read file lineby-line until end of the file. Only use input file stream to extract values from file NO STRINGSTREAMs). You can use the following code to read a line from file (in_file is your input file handler name): in_file > first > fast > hours_worked >> hourly_pay; fore you can create an object Employee, you will need to create two variables (a ing name, and a double salary): - Merge last and fist names into a single string and save it in variable name of type string: (EX: "McMillan" and "Steve" "McMillan, Steve") - Calculate gross pay of an employee using values read from text file and save it in variable salary of type double: CASE 1 / / Employee worked at most 40 hours per week. Hours_worked = value read from file Regular_pay = value read from file / / salary calculation: Salary = Hours_worked * Regular_pay CASE 2 / / Employee worked over 40 hours per week. Hours_worked = value read from file Regul pay = value read from file // Compute overtime hours and pay Overtime_hours = Hours_worked -40 Overtime_pay = Regular_pay 1.5 / Calculate salary: Salary = 40 * Regular_pay + Overtime_hours * Overtime_pay 2) Create an object Employee using name and salary calculated above. 3) Add Employee object to the vector of Employees using appropriate vector function. 4) Close the file after all records are extracted. void sort (/ * pass in vector of employees by address or copy */) This function will sort the vector of Employees based on their salary. To do that, iterate vver the vector and use bubble sort to sort original vector of Employee records in ncreasing order by salary. Make sure you keep the changes. void print (/ pass in vector of employees by address or copy / ) This function will print sorted employee records to console formatted the same way as the output in Sample Run. To do that, iterate over the vector and use Employee class's print inction to print each employee record. 3. MAIN FUNCTION In the main function, you should initialize a vector of Employees and name it records.. Main function will make calls to helper functions to perform the following tasks: 1) read text file and populate vector 2) sort vector in increasing order 3) print sorted vector 4) print employee with highest and lowest salaries. You do not need a function for that because your vector will be sorted, and you will print the first and the last values of the vector. Sample Run Hughes, Helena 73.75 Gill, Aiyana 254.10 Davenport, Trevon 292.88 Oneal, Miles 295.00 Boone, Nathaly 330.00 Waters, Dario 330.00 Gallagher, Chaim 330.00 Hill, Trevor 398.06 Lopez, Byron 435.60 Berger, Tessa 484.00 Elyse, Hallie 484.00 Hebert, Jerry 556.60 Hawkins, Alyson 567.88 Berry, Alexandra 590.00 Smith, Elyse 590.00 Garner, Mariah 627.00 Forster, Randy 627.00 Craig, Melany 634.25 Cabrera, Paris 719.81 Snow, Lawson 2075.00 Employee with the lowest salary: Hughes, Helena 73.75 Employee with the highest salary: Snow, Lawson 2075.00 Submission After you implemented your code, you should have - employee.h - employee.cpp - CS215Lab_Midterm.cpp (where your main was written). Zip these three files and name your zip folder CS215Lab_Midterm (you will lose points if you name files incorrectly or submit other VS files) and submit it to Canvas by 8:30PM

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction To Constraint Databases

Authors: Peter Revesz

1st Edition

1441931554, 978-1441931559

More Books

Students also viewed these Databases questions