# Answer to Question #351039 in C++ for matilda

Question #351039

Problem: The program will determine the gross wages of each employee type, salaried and hourly, and output the total gross wages to be paid for each employee type.

Prompt the user to enter the number of employee wages to be calculated.

1.The program will end when the data for all the employees has been entered.

2. For each employee, indicate if the employee is salaried or paid hourly.

3. Define and implement functions for the following:

a) If the employee is salaried, enter the annual salary. The gross for that employee will be determined by dividing the annual salary by 24. Add the result to the total salaried wage. b) If the employee is paid hourly, enter hours worked (40 ≥ hours ≥ 0) and rate per hour. The gross for that employee is determined by multiplying hours worked by rate per hour. Add the result to the total hourly wages.

4. After performing the calculations for each employee, display the total wages for salaried employees, total wages for hourly employees, and total gross wages.

1
2022-06-17T13:56:39-0400
#include <iostream>
#include <iomanip>

int main() {
int more = 0;
bool salaried;
float totalSalariedWage = 0;
float totalHourlyWage = 0;
float totalGrossWage = 0;

do {
std::cout << "The employee is salaried or paid hourly? (0 - Salaried, 1 - Paid hourly) ";
std::cin >> salaried;

if (!salaried) {
} else {
}
std::cout << "Do you want add one more employee? (0 - No, 1 - Yes) ";
std::cin >> more;
} while (more == 1);

if ((int)totalSalariedWage % 1 != 0 || (int)totalHourlyWage % 1 != 0 || (int)totalGrossWage % 1 != 0) {
std::cout << std::fixed;
std::cout << std::setprecision(2);
}

std::cout << "\nTotal wages for salaried employees: " << totalSalariedWage << "\n";
std::cout << "Total wages for hourly employees: " << totalHourlyWage << "\n";
std::cout << "Total gross wages: " << totalGrossWage << std::endl;
return 0;
}

void addSalaried(float& totalSalariedWage, float& totalGrossWage) {
float annual;

std::cout << "Enter annual salary: ";
std::cin >> annual;
totalSalariedWage += annual / (float)24;
totalGrossWage += annual / (float)24;
}

void addHourly(float& totalHourlyWage, float& totalGrossWage) {
float hours, rate;

std::cout << "Enter hours worked: ";
std::cin >> hours;
if (hours < 0 || hours > 40) {
std::cout << "Hours could be wrong! Re-enter please: ";
std::cin >> hours;
}
std::cout << "Enter rate per hour: ";
std::cin >> rate;
totalHourlyWage += hours * rate;
totalGrossWage += hours * rate;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!