---------------------------------------Original Question----------------------------------------------------------------- 11. Payroll Design a PayRoll class that has data members for an employee’s hourly pay rate, number of hours worked, and total pay for the week. Write a program with an array of seven PayRoll objects. The program should ask the user for the number of hours each employee has worked and will then display the amount of gross pay each has earned. Input Validation: Do not accept values greater than 60 for the number of hours worked. Creating·7·Payroll·objects.↵ Enter·the·#·0·employee's·rate·of·pay·per·hour:12.22↵ Enter·the·#·0·employee's·hours·worked·for·the·week:22↵ Enter·the·#·1·employee's·rate·of·pay·per·hour:99.99↵ Enter·the·#·1·employee's·hours·worked·for·the·week:36↵ Enter·the·#·2·employee's·rate·of·pay·per·hour:45.67↵ Enter·the·#·2·employee's·hours·worked·for·the·week:20↵ Enter·the·#·3·employee's·rate·of·pay·per·hour:56.78↵ Enter·the·#·3·employee's·hours·worked·for·the·week:0↵ Enter·the·#·4·employee's·rate·of·pay·per·hour:40.45↵ Enter·the·#·4·employee's·hours·worked·for·the·week:5↵ Enter·the·#·5·employee's·rate·of·pay·per·hour:30.35↵ Enter·the·#·5·employee's·hours·worked·for·the·week:80↵ Enter·the·#·6·employee's·rate·of·pay·per·hour:30.33↵ Enter·the·#·6·employee's·hours·worked·for·the·week:45↵ ↵ ↵ Employee·#·0·worked·22.00·hours·at·$12.22·for·a·gross·pay·of·$268.84↵ Employee·#·1·worked·36.00·hours·at·$99.99·for·a·gross·pay·of·$3599.64↵ Employee·#·2·worked·20.00·hours·at·$45.67·for·a·gross·pay·of·$913.40↵ Employee·#·3·worked·0.00·hours·at·$56.78·for·a·gross·pay·of·$0.00↵ Employee·#·4·worked·5.00·hours·at·$40.45·for·a·gross·pay·of·$202.25↵ Employee·#·5·worked·60.00·hours·at·$30.35·for·a·gross·pay·of·$1821.00↵ Employee·#·6·worked·45.00·hours·at·$30.33·for·a·gross·pay·of·$1364.85↵
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
11. Payroll
Design a PayRoll class that has data members for an employee’s hourly pay rate, number of hours worked of type double. The default constructor will set the hours worked and pay rate to zero. The class must have a mutator function to set the pay rate for each employee and hours worked. The class should include accessors for both the hours worked and the rate of pay. The class should lastly have a getGross function that will return a double calculated by multiplying the hours worked by the rate
of pay.
Write a
Input Validation: Do not accept values greater than 60 for the number of hours worked, simply have the set function set number of hours worked to 60, the maximum allowed.
---------------------------------------Original Question-----------------------------------------------------------------
11. Payroll
Design a PayRoll class that has data members for an employee’s hourly pay rate, number of hours worked, and total pay for the week. Write a program with an array of seven PayRoll objects. The program should ask the user for the number of hours each employee has worked and will then display the amount of gross pay each has earned.
Input Validation: Do not accept values greater than 60 for the number of hours worked.
Creating·7·Payroll·objects.↵ Enter·the·#·0·employee's·rate·of·pay·per·hour:12.22↵ Enter·the·#·0·employee's·hours·worked·for·the·week:22↵ Enter·the·#·1·employee's·rate·of·pay·per·hour:99.99↵ Enter·the·#·1·employee's·hours·worked·for·the·week:36↵ Enter·the·#·2·employee's·rate·of·pay·per·hour:45.67↵ Enter·the·#·2·employee's·hours·worked·for·the·week:20↵ Enter·the·#·3·employee's·rate·of·pay·per·hour:56.78↵ Enter·the·#·3·employee's·hours·worked·for·the·week:0↵ Enter·the·#·4·employee's·rate·of·pay·per·hour:40.45↵ Enter·the·#·4·employee's·hours·worked·for·the·week:5↵ Enter·the·#·5·employee's·rate·of·pay·per·hour:30.35↵ Enter·the·#·5·employee's·hours·worked·for·the·week:80↵ Enter·the·#·6·employee's·rate·of·pay·per·hour:30.33↵ Enter·the·#·6·employee's·hours·worked·for·the·week:45↵ ↵ ↵ Employee·#·0·worked·22.00·hours·at·$12.22·for·a·gross·pay·of·$268.84↵ Employee·#·1·worked·36.00·hours·at·$99.99·for·a·gross·pay·of·$3599.64↵ Employee·#·2·worked·20.00·hours·at·$45.67·for·a·gross·pay·of·$913.40↵ Employee·#·3·worked·0.00·hours·at·$56.78·for·a·gross·pay·of·$0.00↵ Employee·#·4·worked·5.00·hours·at·$40.45·for·a·gross·pay·of·$202.25↵ Employee·#·5·worked·60.00·hours·at·$30.35·for·a·gross·pay·of·$1821.00↵ Employee·#·6·worked·45.00·hours·at·$30.33·for·a·gross·pay·of·$1364.85↵
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 5 images