Hello everyone.
I'm new to DaniWeb and new to programming with t C++
i have been working on a problem for several days now and I think i may have the code correct except i'm getting compiling errors related to my if..else statements in the GetGrossPay function. I've tried moving the brackets every which way but i still get the same errors.
I dont know if its the IF statements that are the problem or if its the braces that are teh problem. If possible i would like to get some feedback on this.
I've remarked out the printoutput function definition as it was generating garbage on the screen. why would that happen?
#include <iomanip> //precompiler directives
#include <iostream>
#include <string>
using namespace std;
void GetEmployeeData (string &EmpNamef, int &EmpIdf,float &hrsWorkedf,float &hrlyRatef);
void ComputeGrossPay (float hrsWorkedf, float hrlyRatef, float &grossPayf, float ®Pay, float &oTPay);
//void PrintOutput(&EmpNamef,&EmpIdf,&hrsWorkedf,&hrlyRatef,&grossPayf);
void main()
{ //start of main functio
//declare local identifiers
string EmpName;
int EmpId;
float hrsWorked,hrlyRate,regPay,oTPay;
float grossPay;
GetEmployeeData (EmpName,EmpId,hrsWorked,hrlyRate); //call function to get employee data
ComputeGrossPay (hrsWorked,hrlyRate,grossPay,regPay,oTPay); //call function to calculate pay
//void PrintOutput(empName,EmpIdf,hrsWorkedf,hrlyRatef,grossPayf); //call function to print output
return;
}
//start function to get employee data
void GetEmployeeData (string &EmpNamef, int &EmpIdf,float &hrsWorkedf,float &hrlyRatef)
{
string fname, lname;
int empIdf;
// float hrlyRate, hrsWorked;
cout<<"Please enter the employees first and last name separated by a space: \n";
cin>>fname>>lname;
cout<<"Enter the employee ID number: \n";
cin>>empIdf;
//cout<<"Enter the employee's hourly wage: \n";
//cin>>hrlyRate;
//cout<<"Enter the number of hours worked for the previous work week: \n";
//cin>>hrsWorked;
EmpNamef= fname + ' ' + lname;
} //END function to get employee data
//BEGIN function to compute gross pay
void ComputeGrossPay (float hrsWorkedf, float hrlyRatef, float &grossPayf, float ®Payf, float &oTPayf)
{
float hrsWorked,hrlyRate,grossPay,regPay,oTPay;
const float REGWEEK = 40.00;
hrlyRate = 0;
hrsWorked = 0;
cout<<"Enter the number of hours worked: \n";
cin>>hrsWorked;
if ((hrsWorked <= REGWEEK) && (hrsWorked !=0))
{
cout<<"Enter the hourly rate for this employee: \n";
cin>>hrlyRate;
grossPay = hrsWorked * hrlyRate;
cout<<fixed<<showpoint<<setprecision(2);
cout<<"This employee is not eligible for OT. The gross pay is: "<<grossPay<<endl;
else if(hrsWorked > REGWEEK)
cout<<"enter hourly rate: \n";
cin>>hrlyRate;
oTPay = ((hrlyRate * 1.5) * (hrsWorked - 40));
regPay = (REGWEEK * hrlyRate);
grossPay = (regPay + oTPay);
cout<<fixed<<showpoint<<setprecision(2);
cout<<"This employee is eligible for OT. The gross pay is: $"<<grossPay<<endl;
else
}
cout<<"Hourly employees who do not work can not receive a pay check."<<endl;
} //end of compute gross pay function
//void PrintOutput(empName,&EmpIdf,&hrsWorkedf,&hrlyRatef,&grossPayf)
//{
// string lNamef;
// int EmpIdf;
// float hrsWorkedf,hrlyRatef;
// float grossPayf;
//empName,EmpIdf,hrsWorkedf,hrlyRatef,grossPayf
//cout<<"\n\n"<<setw(40)<<"Employee Payroll Program";
//cout<<endl<<endl;
//cout<<"\tName\tEmployee ID\t Hours Worked\t Hourly Rate \t Gross Pay \n\n";
}