Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ Program Comment Program Please! Sructured Data Multipurpose Payroll Write a

ID: 3632453 • Letter: C

Question

C++ Program
Comment Program Please!
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. C++ Program
Comment Program Please!
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.

Explanation / Answer

please rate - thanks

#include <iostream>
#include <iomanip>
#include <cctype>
using namespace std;
struct Hourly
{double hoursWorked;
double hourlyRate;
};
struct Salaried
{double salary;
double bonus;
};
union PayPackage
{Hourly h;
Salaried s;
};
int main()
{PayPackage pay;
char choice;
double salary;
bool error;
cout<<setprecision(2)<<fixed<<showpoint;
do
{
cout<<"Enter type of worker ";
cout<<"(H)ourly ";
cout<<"(S)alaried ";
cin>>choice;
choice=toupper(choice);
error=false;
switch(choice)
   {case 'H': cout<<"Enter hours worked: ";
              cin>>pay.h.hoursWorked;
              while(pay.h.hoursWorked<0||pay.h.hoursWorked > 80)
                 {cout<<"Invalid entry-must be between 0 and 80: ";
                  cout<<"Enter hours worked: ";
                  cin>>pay.h.hoursWorked;
                  }
              cout<<"Enter hourly rate: ";
              cin>>pay.h.hourlyRate;
              while(pay.h.hourlyRate < 0)
                  {cout<<"Invalid entry-must be >=0: ";
                   cout<<"Enter hourly rate: ";
                   cin>>pay.h.hourlyRate;    
                   }
              salary=pay.h.hourlyRate * pay.h.hoursWorked;
              break;
      case 'S': cout<<"Enter salary: ";
                cin>>pay.s.salary;
                while(pay.s.salary<0)
                   {cout<<"Invalid entry-must be >=0: ";
                    cout<<"Enter salary: ";
                    cin >> pay.s.salary;
                   }
                cout<<"Enter bonus: ";
                cin>>pay.s.bonus;
                while(pay.s.bonus<0)
                  {cout<<"Invalid entry-must be >=0: ";
                  cout<<"Enter bonus: ";
                  cin>>pay.s.bonus;
                  }
                  salary=pay.s.salary + pay.s.bonus;
                  break;
       default: cout<<"invalid entry-must be H or S ";
                 error=true;
       }
       }while(error);        
      cout<<"Pay=$"<<setprecision(2)<<fixed<<showpoint<<salary<<endl;
system("pause");
return 0;
}




Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote