Payroll class help!

Design a Payroll class that has fields for an employee's name, ID number,
hourly pay rate, and number of hours worked. Write the appropriate accessor
and mutator methods and a constructor that accepts the employee's name and
ID number as arguments. The class should also have a method that returns the
employees gross pay, which is calculated as the number of hours worked
multiplied by the hourly pay rate.
Your program will also have a main program, which creates one object of that
class, initializes the fields of that object and calls the grossPay method (which
is defined in the Payroll class).
The main program will ask for the Employee name, ID, pay rate, and hours
worked. It will output the gross pay.

This is what I have to do. I have a bit of code, but not enough to really go on, I'll post in anyways. However, this is dipping my feet into OOP and I want to understand my professor again is assuming that I'm going to learn everything from a book without some kind of explanation, so if y'all could include those that would be fantastic! Thank you in advance for y'alls help

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
#include <iostream>
#include <string>

using namespace std;

class Payroll
{

public:
	Payroll();   // Constructior





};

int main()
{

	int Ename;
	int Eid;
	int HrsWrkd;
	int payRate;

	cout << "Please enter the Employee name: ";
	cin >> Ename;

	cout << "Please enter the ID: ";
	cin >> Eid;

	cout << "Please enter the pay rate: ";
	cin >> payRate;

	cout << "Please enter hours worked: ";
	cin >> HrsWrkd;






	system("pause");

	return 0;
}
This is my updated code!

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
#include <iostream>
#include <string>
#include <cmath>
#include <iomanip>

using namespace std;

class Payroll
{

public:
	Payroll();   // Constructor
	string getEname();
	int Eid();
	double getPayRate() const;
	int getHrsWrkd() const;
	double getGrossPay() const;

};


int main()
{
	
	Payroll();
	string getEname;
	int Eid;
	int getHrsWrkd;
	double getPayRate;
	float grossPay;

	cout << "Please enter the Employee name: " << endl;
	cin >> getEname;

	cout << "Please enter the ID: " << endl;
	cin >> Eid;

	cout << "Please enter the pay rate: " << endl;
	cin >> getPayRate;

	cout << "Please enter hours worked: " << endl;
	cin >> getHrsWrkd;

	// Calculate gross pay and display
	grossPay = getHrsWrkd * getPayRate;
	cout << setprecision(5);

	cout << "The gross pay is $" << grossPay << endl;


	system("pause");

	return 0;
}
Topic archived. No new replies allowed.