Question

In: Computer Science

Write a program that calculates pay for either hourly paid workers or salaried workers. Hourly paid...

Write a program that calculates pay for either hourly paid workers or salaried workers. Hourly paid workers are paid their hourly pay rate times the number of hours worked. Salaried workers are payed their regular salary plus any bonus they may have earned. The program should declare two structures for the following data:

• Hourly Paid

HoursWorked

◦ HourlyRate

• Salaried

◦ Salary

◦ Bonus

The program should also declare a structure 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 pay for an hourly paid worker or a salaried worker. Regardless of what 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 numbers. Do not accept values greater than 80 for hours worked.

Optional: you may use C++ objects in place of structs to represent salaried and hourly employees

USING C++

Solutions

Expert Solution

This below script is written as per given in the probelm statement.ie created two structures for salary and hourly workeers seperately and calculated the salary and displayed the result and validated the number hours should be positive and not greter than 80..

Code:

#include<iostream>
using namespace std;

// Created HourlyWorker Structure with Hours worked and payrate
struct HourlyWorker
{
private:
int HoursWorked;
int HourlyRate;
public:
   // Initialise the data members with default values
HourlyWorker()
{
HoursWorked = 0;
HourlyRate = 0;
}
   // Initialise the data members from the object
HourlyWorker(int a, int b)
{
HoursWorked = a;
HourlyRate = b;
}
   // Calculating Salary
void calculate()
{
cout<<"Hourly Worker Payment is: "<<HourlyRate * HoursWorked<<endl;
}
};

// Created SalaryWorker Structure with Salary worked and Bonus
struct SalaryWorker
{
private:
int Salary;
int Bonus;
public:
// Initialise the data members with default values
SalaryWorker()
{
Salary = 0;
Bonus = 0;
}
   // Initialise the data members from the object
SalaryWorker(int a, int b)
{
Salary = a;
Bonus = b;
}
       // Calculating Salary
void calculate()
{
cout<<"Salaried Employee Salary with Bonus is: "<<Salary + Bonus <<endl;
}
};

int main()
{

  
cout<<"Enter Number of Hours in Positive only and not greater than 80 Hours:"<<endl;
int hour;
cin>>hour;
   // Checking the number of hours are postive and not greater than 80
if(80 >hour && 0 <hour)
{
HourlyWorker h(hour,10);
h.calculate();
SalaryWorker s(50,20);
s.calculate();
}
else
{
cout<<"Re-Enter Hours"<<endl;
cin>>hour;
HourlyWorker h(hour,10);
h.calculate();
SalaryWorker s(50,20);
s.calculate();
}

return 0;
}

Output:


Related Solutions

Write a C++ program that calculates pay for either hourly paid workers or salaried workers.
Write a C++ program that calculates pay for either hourly paid workers or salaried workers. Hourly paid workers are paid their hourly pay rate times the number of hours worked. Salaried workers are payed their regular salary plus any bonus they may have earned. The program should declare two structures for the following data:• Hourly Paid◦ HoursWorked◦ HourlyRate• Salaried◦ Salary◦ BonusThe program should also declare a structure with two members. Each member should be a structure variable: one for the...
In C++, Write a program that calculates pay for either an hourly paid worker or a...
In C++, Write a program that calculates pay for either an hourly paid worker or a 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: HoursWorked HourlyRate Salaried: Salary Bonus The program should also declare a union with two members. Each member should be a structure...
Write a C program that calculates a worker’s wages from their hours worked and hourly rate....
Write a C program that calculates a worker’s wages from their hours worked and hourly rate. This wage calculator should also account for overtime hours, calculate amount to be witheld from taxes, and calculate the final net income. Required functionality: 1. Ask the user for the number of hours worked and hourly rate in dollars. The program should be able to accept decimal values for both of these (e.g. 3.2 hours, 11.25 dollars/hour) 2. Overtime hours are those worked in...
Pay Packages Explained Executive pay packages differ substantially from typical salaried or hourly employee compensation because...
Pay Packages Explained Executive pay packages differ substantially from typical salaried or hourly employee compensation because unlike typical employee pay, the vast majority of an executive's pay is contingent compensation and structured only to reward the executive for actual, positive company performance and growth in shareholder value. To this end, executive compensation packages typically utilize six distinct compensation components: Base Salary Short-Term Incentive Long-Term Incentive Employee Benefits Perquisites Severance/Change-in-Control Payments A company's Compensation Committee will structure their executive's pay packages...
If firms increase the hourly wage paid to all workers then (all else the same) this...
If firms increase the hourly wage paid to all workers then (all else the same) this will tend to: Group of answer choices increase the price of the goods sold by the firms because of a decrease in supply. increase the price of the goods sold by the firms because of an increase in supply. decrease the price of the goods sold by the firms because of a decrease in supply. decrease the price of the goods sold by the...
Please use Phyton to write a program: Write a program that calculates and displays the total...
Please use Phyton to write a program: Write a program that calculates and displays the total bill at a restaurant for a couple that is dining. The program should collect from the couple, cost of each meal, and the percentage of the final cost that they would like to tip. The sales tax in the state where the restaurant exists is 7.5%. Display to the user, line by line: Total Cost of Both Meals Sales Tax in dollars Tip in...
About 5​% of hourly paid workers in a region earn the prevailing minimum wage or less....
About 5​% of hourly paid workers in a region earn the prevailing minimum wage or less. A grocery chain offers discount rates to companies that have at least 30 employees who earn the prevailing minimum wage or less. Complete parts​ (a) through​ (c) below. ​(a) Company A has 299 employees. What is the probability that Company A will get the​ discount?
About 5​% of hourly paid workers in a region earn the prevailing minimum wage or less....
About 5​% of hourly paid workers in a region earn the prevailing minimum wage or less. A grocery chain offers discount rates to companies that have at least 30 employees who earn the prevailing minimum wage or less. Complete parts​ (a) through​ (c) below. ​(a) Company A has 287 employees. What is the probability that Company A will get the​ discount? ​(Round to four decimal places as​ needed.) ​(b) Company B has 501 employees. What is the probability that Company...
In C Program #include Create a C program that calculates the gross and net pay given...
In C Program #include Create a C program that calculates the gross and net pay given a user-specified number of hours worked, at minimum wage. The program should compile without any errors or warnings (e.g., syntax errors) The program should not contain logical errors such as subtracting values when you meant to add (e.g., logical errors) The program should not crash when running (e.g., runtime errors) When you run the program, the output should look like this: Hours per Week:...
True or False. The FLSA does not require employers to pay hourly workers a minimum wage...
True or False. The FLSA does not require employers to pay hourly workers a minimum wage or overtime?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT