The following was of no help: http://www.java2s.co...llitsmethod.htm
header:
#ifndef PayRoll_H
#define PayRoll_H
#include <string>
//using namespace std
class PayRoll
{
private:
string name, department, position;
int id;
double hours, payRate;
public:
PayRoll()
{
name = " ";
id = 0;
department = " ";
position = " ";
}
//~PayRoll ();
// Set array elements to numArray's index
void setName(string n)
{ name = n; }
void setDep (string d)
{ department = d; }
void setPos (string p)
{ position = p; }
void setID (int i)
{
id = i;
}
void setHours (double h)
{
hours = h;
}
void setPay (double pr)
{
payRate = pr;
}
//Accessor fucntions.
string getName() const
{ return name; }
string getDep() const
{ return department; }
string getPos() const
{ return position; }
int getID() const
{ return id; }
double getHours() const
{ return hours; }
double getPay()
{
if (position == "Team lead")
payRate = 25;
else if (position == "Representative")
payRate = 20;
else
payRate = 15;
return payRate;
}
double getGrossPay () const
{ return hours * payRate; }
};
#endif
main
#include <iostream>
#include <string>
#include "PayRoll.h"
using namespace std ;
int main()
{
const int Num_Emps = 4;
int numbers;
//string name, dep, pos;
//int id;
int hours, payRate;
PayRoll Employee[Num_Emps] = { {"John Doe", 10, "Technician", "Team lead"}
{"Mary Smith", 12, "Human Resource", "Agent"}
{"Karen Benton ", 14, "Human Resource", "Representative"}
{"Shawn Grey", 16, "Technician", "Agent"}
};
cout << "Enter employee info: " << endl;
for (int i = 0; i < Num_Emps; i++)
{
do
{
cout << "Hours worked by " << Employee[i].getName() << ": ";
cin >> hours;
} while (hours <= 60);
Employee[i].setHours(hours);
}
cout << "Employee Earnings: \n";
for (int i = 0; i < Num_Emps; i++)
{
cout << "Employee " << i+1 << " data:";
cout << "\nName: " << Employee[i].getName();
cout << "\nID : " << Employee[i].getID();
cout << "\nDepartment: " << Employee[i].getDep();
cout << "\nPosition : " << Employee[i].getPos();
cout << "\n\nHours worked: " << Employee[i].getHours();
cout << "\nGross Pay : " << Employee[i].getGrossPay();
}
system("pause");
return 0;
}
This post has been edited by mgrex: 17 September 2012 - 07:03 PM

New Topic/Question
Reply



MultiQuote



|