I am having trouble storing this information as a record. Theteacher implied to
ID: 3609071 • Letter: I
Question
I am having trouble storing this information as a record. Theteacher implied to use a struct but we have not gone over this yet.Also, I am having trouble with the user to input the path of thefile to be written to and 'zero' to stop entering employees.The program should start prompting user to enter a path towrite the record to. Then user enters ID (numbers and letters),their hours worked, and then their pay rate. It will then loop forthe next employee until a zero is entered to stop enteringemployees. Then program will print the information including totalpay plus if any overtime to the screen and to the file specified inthe beginning.
When I have the 'struct Pay' uncommented it doesn't work, saysthe variables are #ff0000.
Any help is appreciated. Below is what I have so far.TIA
//********main.cpp******* #include <iostream> #include <fstream> #include <cstring> #include <cstdlib> #include "Utility.h" using namespace std;
int main() { /* struct Pay { int empID[80]; float payRate[80]; float hours[80]; float total[80]; } */ float payRate; float hours; float total; int empID; ofstream payFile;
payFile.open("payfile.txt"); total = 0.0; cout << "Enter employee ID:"; cin >> empID; while (empID != 0) { cout << "Enter payrate: "; cin >>payRate; cout << "Enter hoursworked: "; cin >>hours; CalcPay(payRate, hours,total); payFile << empID<< payRate << hours << total; cout << "Enter employeenumber: "; cin >>empID; } system ("PAUSE"); return 0; } //*******main.cpp******
//******Utility.cpp****** #include <iostream> #include "Utility.h"
void CalcPay( float payRate, float hours, float&total) { if (hours > MAX_HOURS) total = (MAX_HOURS * payRate)+ (hours - MAX_HOURS) * payRate * OVERTIME; else total = hours *payRate; } //*******Utility.cpp******
//*******Utility.h******** #include <iostream> #include <fstream> using namespace std;
void CalcPay( float, float, float& ); const float MAX_HOURS = 40.0;
const float OVERTIME = 1.5;
//*******Utility.h********
The program should start prompting user to enter a path towrite the record to. Then user enters ID (numbers and letters),their hours worked, and then their pay rate. It will then loop forthe next employee until a zero is entered to stop enteringemployees. Then program will print the information including totalpay plus if any overtime to the screen and to the file specified inthe beginning.
When I have the 'struct Pay' uncommented it doesn't work, saysthe variables are #ff0000.
Any help is appreciated. Below is what I have so far.TIA
//********main.cpp******* #include <iostream> #include <fstream> #include <cstring> #include <cstdlib> #include "Utility.h" using namespace std;
int main() { /* struct Pay { int empID[80]; float payRate[80]; float hours[80]; float total[80]; } */ float payRate; float hours; float total; int empID; ofstream payFile;
payFile.open("payfile.txt"); total = 0.0; cout << "Enter employee ID:"; cin >> empID; while (empID != 0) { cout << "Enter payrate: "; cin >>payRate; cout << "Enter hoursworked: "; cin >>hours; CalcPay(payRate, hours,total); payFile << empID<< payRate << hours << total; cout << "Enter employeenumber: "; cin >>empID; } system ("PAUSE"); return 0; } //*******main.cpp******
//******Utility.cpp****** #include <iostream> #include "Utility.h"
void CalcPay( float payRate, float hours, float&total) { if (hours > MAX_HOURS) total = (MAX_HOURS * payRate)+ (hours - MAX_HOURS) * payRate * OVERTIME; else total = hours *payRate; } //*******Utility.cpp******
//*******Utility.h******** #include <iostream> #include <fstream> using namespace std;
void CalcPay( float, float, float& ); const float MAX_HOURS = 40.0;
const float OVERTIME = 1.5;
//*******Utility.h********
The program should start prompting user to enter a path towrite the record to. Then user enters ID (numbers and letters),their hours worked, and then their pay rate. It will then loop forthe next employee until a zero is entered to stop enteringemployees. Then program will print the information including totalpay plus if any overtime to the screen and to the file specified inthe beginning.
When I have the 'struct Pay' uncommented it doesn't work, saysthe variables are #ff0000.
Any help is appreciated. Below is what I have so far.TIA
//********main.cpp******* #include <iostream> #include <fstream> #include <cstring> #include <cstdlib> #include "Utility.h" using namespace std;
int main() { /* struct Pay { int empID[80]; float payRate[80]; float hours[80]; float total[80]; } */ float payRate; float hours; float total; int empID; ofstream payFile;
payFile.open("payfile.txt"); total = 0.0; cout << "Enter employee ID:"; cin >> empID; while (empID != 0) { cout << "Enter payrate: "; cin >>payRate; cout << "Enter hoursworked: "; cin >>hours; CalcPay(payRate, hours,total); payFile << empID<< payRate << hours << total; cout << "Enter employeenumber: "; cin >>empID; } system ("PAUSE"); return 0; } //*******main.cpp******
//******Utility.cpp****** #include <iostream> #include "Utility.h"
void CalcPay( float payRate, float hours, float&total) { if (hours > MAX_HOURS) total = (MAX_HOURS * payRate)+ (hours - MAX_HOURS) * payRate * OVERTIME; else total = hours *payRate; } //*******Utility.cpp******
//*******Utility.h******** #include <iostream> #include <fstream> using namespace std;
void CalcPay( float, float, float& ); const float MAX_HOURS = 40.0;
const float OVERTIME = 1.5;
//*******Utility.h********
#include <iostream> #include <fstream> #include <cstring> #include <cstdlib> #include "Utility.h" using namespace std;
int main() { /* struct Pay { int empID[80]; float payRate[80]; float hours[80]; float total[80]; } */ float payRate; float hours; float total; int empID; ofstream payFile;
payFile.open("payfile.txt"); total = 0.0; cout << "Enter employee ID:"; cin >> empID; while (empID != 0) { cout << "Enter payrate: "; cin >>payRate; cout << "Enter hoursworked: "; cin >>hours; CalcPay(payRate, hours,total); payFile << empID<< payRate << hours << total; cout << "Enter employeenumber: "; cin >>empID; } system ("PAUSE"); return 0; } //*******main.cpp******
//******Utility.cpp****** #include <iostream> #include "Utility.h"
void CalcPay( float payRate, float hours, float&total) { if (hours > MAX_HOURS) total = (MAX_HOURS * payRate)+ (hours - MAX_HOURS) * payRate * OVERTIME; else total = hours *payRate; } //*******Utility.cpp******
//*******Utility.h******** #include <iostream> #include <fstream> using namespace std;
void CalcPay( float, float, float& ); const float MAX_HOURS = 40.0;
const float OVERTIME = 1.5;
//*******Utility.h********
#include <iostream> #include "Utility.h"
void CalcPay( float payRate, float hours, float&total) { if (hours > MAX_HOURS) total = (MAX_HOURS * payRate)+ (hours - MAX_HOURS) * payRate * OVERTIME; else total = hours *payRate; } //*******Utility.cpp******
//*******Utility.h******** #include <iostream> #include <fstream> using namespace std;
void CalcPay( float, float, float& ); const float MAX_HOURS = 40.0;
const float OVERTIME = 1.5;
#include <iostream> #include <fstream> using namespace std;
void CalcPay( float, float, float& ); const float MAX_HOURS = 40.0;
const float OVERTIME = 1.5;
//*******Utility.h********
Explanation / Answer
struct Pay { int empID[80]; float payRate[80]; float hours[80]; float total[80]; };Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.