G
GRoll21
Hey this is my first time posting on of these. the program just gets
the employee number, then it gets hours, how much they get paid, then
figures total. for some reason its not liking my last fucntion. this is
the 1 error it gives me. i'm not done with the program yet but I can't
really go on till I figure this out. I need to add somes pushbacks in
there for it to be done. i got it commented out at the bottom where it
says the problem is. its the last function. any help or advice would be
great. thanks to all.
c:\C++\vector\vector.cpp(85): error C2676: binary '*' :
'std::vector<_Ty>' does not define this operator or a conversion to a
type acceptable to the predefined operator
with
[
_Ty=int
]
#include <iostream>
#include <iomanip>
#include <vector>
using namespace std;
//prototypes
void getInfo(vector<int>, vector<int>, vector<float>, vector<float>);
// Get input for the hours and payRate arrays
void calcPay(vector<int>, vector<float>, vector<float>, int); //
Calculate the values for the wages array
void printInfo(vector<int>, vector<int>, vector<float>, vector<float>);
// Print all array values
int main()
{
vector<int> empId;
empId[0] = 5658845;
empId[1] = 4520125;
empId[2] = 7895122;
empId[3] = 8777541;
empId[4] = 8451277;
empId[5] = 1302850;
empId[6] = 7580489;
vector<int> hours(7); // holds employee's hours
vector<float> payRate(7); //holds employee's hourly pay rate
vector<float> wages(7); // holds employee's gross wages
getInfo(empId, hours, payRate, wages);
printInfo(empId, hours, payRate, wages);
return 0;
}
void getInfo(vector<int> empId, vector<int> hours, vector<float>
payRate, vector<float> wages)
{
for (int index = 0; index < 7; index++)
{ system("cls");
cout << "Info for employee Number: " << empId[index] <<"\n";
cout << "Hours: ";
cin >> hours[index];
while(hours[index] < 0)
{
cout << "\nPlease enter a non negative number. ";
cin >> hours[index];
}
cout << "Pay Rate: $";
cin >> payRate[index];
while(payRate[index] < 6.00)
{
cout <<"\nPlease enter a realistic pay rate. $";
cin >> payRate[index];
}
cout << "\n";
calcPay(hours, payRate, wages, index);
}
}
void printInfo(vector<int> empId, vector<int> hours, vector<float>
payRate, vector<float> wages)
{
//header
system("cls");
cout << "\t\tPayroll Information\n\n";
cout << "Employee ID Hours Pay Rate Pay\n";
cout << "----------- ----- -------- ---\n";
for (int index = 0; index < 7; index++)
{
cout << empId[index] << "\t" << setprecision(2)<< fixed << setw(14) <<
hours[index] << setw(11)<< payRate[index] << setw(12)<< wages[index]
<<"\n";
}
cout <<"\n";
}
void calcPay (vector<int> hours[], vector<float> payRate[],
vector<float> wages[],int index)
{
//// this -->> wages[index] = hours[index] * payRate[index];
}
the employee number, then it gets hours, how much they get paid, then
figures total. for some reason its not liking my last fucntion. this is
the 1 error it gives me. i'm not done with the program yet but I can't
really go on till I figure this out. I need to add somes pushbacks in
there for it to be done. i got it commented out at the bottom where it
says the problem is. its the last function. any help or advice would be
great. thanks to all.
c:\C++\vector\vector.cpp(85): error C2676: binary '*' :
'std::vector<_Ty>' does not define this operator or a conversion to a
type acceptable to the predefined operator
with
[
_Ty=int
]
#include <iostream>
#include <iomanip>
#include <vector>
using namespace std;
//prototypes
void getInfo(vector<int>, vector<int>, vector<float>, vector<float>);
// Get input for the hours and payRate arrays
void calcPay(vector<int>, vector<float>, vector<float>, int); //
Calculate the values for the wages array
void printInfo(vector<int>, vector<int>, vector<float>, vector<float>);
// Print all array values
int main()
{
vector<int> empId;
empId[0] = 5658845;
empId[1] = 4520125;
empId[2] = 7895122;
empId[3] = 8777541;
empId[4] = 8451277;
empId[5] = 1302850;
empId[6] = 7580489;
vector<int> hours(7); // holds employee's hours
vector<float> payRate(7); //holds employee's hourly pay rate
vector<float> wages(7); // holds employee's gross wages
getInfo(empId, hours, payRate, wages);
printInfo(empId, hours, payRate, wages);
return 0;
}
void getInfo(vector<int> empId, vector<int> hours, vector<float>
payRate, vector<float> wages)
{
for (int index = 0; index < 7; index++)
{ system("cls");
cout << "Info for employee Number: " << empId[index] <<"\n";
cout << "Hours: ";
cin >> hours[index];
while(hours[index] < 0)
{
cout << "\nPlease enter a non negative number. ";
cin >> hours[index];
}
cout << "Pay Rate: $";
cin >> payRate[index];
while(payRate[index] < 6.00)
{
cout <<"\nPlease enter a realistic pay rate. $";
cin >> payRate[index];
}
cout << "\n";
calcPay(hours, payRate, wages, index);
}
}
void printInfo(vector<int> empId, vector<int> hours, vector<float>
payRate, vector<float> wages)
{
//header
system("cls");
cout << "\t\tPayroll Information\n\n";
cout << "Employee ID Hours Pay Rate Pay\n";
cout << "----------- ----- -------- ---\n";
for (int index = 0; index < 7; index++)
{
cout << empId[index] << "\t" << setprecision(2)<< fixed << setw(14) <<
hours[index] << setw(11)<< payRate[index] << setw(12)<< wages[index]
<<"\n";
}
cout <<"\n";
}
void calcPay (vector<int> hours[], vector<float> payRate[],
vector<float> wages[],int index)
{
//// this -->> wages[index] = hours[index] * payRate[index];
}