I need help fine tuning the subsequent program. Structs has really confused me and i'm trying my best to figure out what to do.
The purpose of this program is to read an employee file as structs in an array of employee data.
- I have to prompt for the name of the input file which I wrote the code for. I wrote the code for the structs.
- Now from the input file I am suppose to read the first integer and create a dynamic array of the correct size to hold the employee information. Right now I have at 4.
- From this create a payroll output file.
- Prompt the user for the name of the output file which I wrote the code for
Now overtime pay is calculated for nonexempt employees. An employee is exempt if "Y" appears in the exempt column. Overtime is paid at a time-and-a-half for all hours worked over 40. If an exempt employee works over 40 hours or under 40 hours, that employee is only paid for 40 hours of work
#include <fstream> // for ifstream
#include <iostream> // for cin, cout and cerr
#include <string> // for string datatype
#include <cstdlib> // needed for the exit function
#include <iomanip>
using namespace std;
struct empData
{
int empNumber;
int department;
double payRate;
double hoursWorked;
char exempt;
};
string getInputFileName(); // a function to prompt for the complete
// input file name
string getOutputFileName(); // a function to prompt for the complete
// output file name
inFile.close(); // close the input file
outFile.close(); // close the output file
//********************************************************************
//
// Function name: getInputFileName
//
// Purpose: to prompt for the fully qualified name of a file
//
// Input parameters: none
//
// Output parameters: none
//
// Return Value: a string containing the fully qualified name of a file
//
//********************************************************************
string getInputFileName()
{
string infName; // fully qualified name of the file
cout << "Please enter the fully qualified name of the " << endl
<< "input data file (i.e. including the path): ";
cin >> infName; // cannot handle blanks in a file name or path
cout << endl; // skip a line
return infName;
}
//********************************************************************
//
// Function name: getbasePay
//
// Purpose: to calculate base pay earning of each employee
//
// Input parameters: none
//
// Output parameters: none
//
// Return Value: a double containing the base pay earning of each
// employee
//
//********************************************************************
//********************************************************************
//
// Function name: getTotal
//
// Purpose: to calculate total final earning of each employee
//
// Input parameters: none
//
// Output parameters: none
//
// Return Value: a double containing the total final earning of each
// employee
//
//********************************************************************
void getTotal()
{
double Total; //
Total = basePay + overTime
return Total;
}
//********************************************************************
//
// Function name: getOutputFileName
//
// Purpose: to prompt for the fully qualified name of a file
//
// Input parameters: none
//
// Output parameters: none
//
// Return Value: a string containing the fully qualified name of a file
//
//********************************************************************
string getOutputFileName()
{
string outfName; // fully qualified name of the file
cout << "Please enter the fully qualified name of the " << endl
<< "output data file (i.e. including the path): ";
cin >> outfName; // cannot handle blanks in a file name or path