C++ Program Sructured Data Multipurpose Payroll Write a program that calculates
ID: 3632533 • Letter: C
Question
C++ Program
Sructured Data
Multipurpose Payroll
Write a program that calculates pay for either an hourly paid worker or salaried worker. Hourly paid workers are paid their hourly pay rate times the number of hours worked. Salaried workers are paid their regular salary plus any bonus they may have earned. The program should declare two structures for the following data:
Hourly Paid:
Hourly Worked
Hourly Rate
Salaried:
Salary
Bonus
The program should also delcare a union with two members. Each member should be a structure variable: one for the hourly paid worker and another for the salaried worker.
The program should ask the user whether he or she is calculating the pay for an hourly paid worker or a salaried worker. Regardless of which the user selects, the appropriate members of the union will be used to store the data that will be used to calculate the pay.
Input Validation: Do not accept negative members. Do not accept values greater than 80 for HoursWorked.
*************************************************************************************************
Don't Include #include <cctype>, Don't include #include "SalariedEmployee.h"
Don't include #include "HourlyEmployee.h"
************************************************************************
Comment Please!
Include For loop, Do statement, if else statement.
#include <iostream>
#include <iomanip>
using namespace std;
struct {
Explanation / Answer
Employee class: Object-oriented languages typically provide a natural way to treat data and functionality as a single entity. In C++, we do so by creating a class. Here is a class definition for a generic Employee: class Employee {public: Employee(string theName, float thePayRate); string getName() const; float getPayRate() const; float pay(float hoursWorked) const;protected: string name; float payRate;}; Note: For now, just think of the "protected" keyword as being like "private". The class consists of: A constructor to initialize fields of the class. Methods to "get" the fields. A method to calculate the employee's pay (given the number of hours worked). Definitions for each of the methods follow: Employee::Employee(string theName, float thePayRate){ name = theName; payRate = thePayRate;}string Employee::getName() const{ return name;}float Employee::getPayRate() const{ return payRate;}float Employee::pay(float hoursWorked) const{ return hoursWorked * payRate;} Note that the payRate is used as an hourly wage. The class would be used something like: #include "employee.h"... Employee empl("John Burke", 25.0); // Print out name and pay (based on 40 hours work). coutRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.