1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
|
// This is the Error I receive when I attempt to compile it I don't
// understand the error could someone help to just explain it to me
// or point me in the right direction.
//In function 'void ProcessPayRoll(const int*, const int*, const float*, int, //const float*, const float*, int)':
//102:16: warning: value computed is not used [-Wunused-value]
//102:16: warning: statement has no effect [-Wunused-value]
//104:39: error: invalid types 'const float*[float]' for array subscript
//------------------------------------------------------------------------
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
const int MAX_EMP = 25;
const int MAX_TAX = 5;
const float TAX_1000 = .035;
const float TAX_2000 = .06;
const float TAX_4000 = .085;
const float TAX_LUX = .12;
const int MAX_OVERTIME = 60;
const int MAX_NORMAL_HOURS = 40;
void GetTaxTable(float taxable[], float taxrate[], int& numTax);
void GetEmpHours(int empid[], int hours[], float hourlyrate[], int& numEmp);
void PrintHeader(int numEmp);
void ProcessPayRoll(const int empid[], const int hours[],
const float hourlyrate[], int numEmp,
const float taxable[], const float taxrate[],
int numTax);
bool OverHoursLimit(int hours);
int FindTaxLevel(float wages, const float taxable[], int size);
float ComputeWages(int hours, float hourlyrate);
void PrintEmpWages(int empid, float wages, float rate, float netpay);
void GetTaxTable(float taxable[],float taxrate[], int& numTax)
{
int length = numTax;
for (int index = 0; index < length; index++)
{
cout << "Enter taxable wages and tax rates:" << endl;
cin >> taxable[index];
cin >> taxrate[index];
}
}
void GetEmpHours(int empid[], int hours[], float hourlyrate[], int& numEmp)
{
int size = numEmp;
for (int k = 0; k < size; k++)
{
cout << "Enter employee ID, hours and hourly rate:" << endl;
cin >> empid[k];
cin >> hours[k];
cin >> hourlyrate[k];
}
}
// Specifically with this function it gives me the error as seen at the top.
void ProcessPayRoll(const int empid[], const int hours[],
const float hourlyrate[], int numEmp,
const float taxable[], const float taxrate[],
int numTax)
{
int emplId = 0;
int hoursEmp;
float rateOfPay = 0;
int wages = 0;
float rateOfTax;
float netPay = 0;
float taxesTaken;
float taxableWages = 0;
for (int a = 0; a < numEmp; a++)
{
emplId = empid[a];
hoursEmp = hours[a];
rateOfPay = hourlyrate[a];
wages = ComputeWages(hoursEmp, rateOfPay);
taxable[a];
taxableWages = FindTaxLevel(wages,taxable, numEmp);
rateOfTax = taxrate[taxableWages];
taxesTaken = wages * rateOfTax;
netPay = wages - taxesTaken;
}
PrintEmpWages(emplId, wages, rateOfPay, netPay);
}
bool OverHoursLimit(int hours)
{
if (hours > MAX_OVERTIME)
return true;
else
return false;
}
int FindTaxLevel(float wages, const float taxable[], int size)
{
int i;
for (i = 0; i < size; i++)
if (taxable[i] <= wages)
return i;
return -1;
}
float CompeterWages(int hours[], float hourlyrate[])
{
float grossPay = 0;
int timeHours = 0;
int timeLeft = 0;
float rate;
for (int h = 0; h < MAX_EMP; h++)
{
timeHours = hours[h];
if (OverHoursLimit(timeHours) == true)
cout << "Abnormal overtime hours! Unable to process!!" << endl;
rate = hourlyrate[h];
if (timeHours > MAX_NORMAL_HOURS)
{
timeLeft = timeHours - MAX_NORMAL_HOURS;
grossPay = (timeLeft * rate) + (MAX_NORMAL_HOURS * rate);
}
else
grossPay = timeHours * rate;
return grossPay;
}
return 0.0;
}
|