Answer to Question #203628 in C++ for Foxxy Macbrown

Question #203628

At the peak of COVID-19, most worker started working from home. Salaries of workers were reduced by 30%. Assuming income tax was also reduced by 50% from the previous rate of 15% and workers were paid on the number of hours worked in a month and each worker is supposed to work a total of 170 hours in a month. All overtime has been cancelled. If a worker does not meet the 170 hours’ threshold for a month, 5% is deducted from the salary. Assuming the hourly rate is GHC 10, Write a c++ program for the scenario narrated above. Your program should:

a) request for an employee’s name, the number of hours worked in a month AP[2 marks]

b) define a function called payRole, your function should compute a worker’s salary and income tax and any deductions if any

c) your program should display the results in “b” above.

AN[10 marks]

AP[3 marks]

d) explain the logic behind the code especially the function


1
Expert's answer
2021-06-05T23:52:59-0400
#include <iostreaem>
#include <map>

std::map<std::string, double> salary;

double payRole(std::string worker, int hours) 
{
  if (hours < 170) return (0.3 - 0.05) * salary[worker];
  else return 0.3 * salary[worker];
}

int main()
{
  map.insert({"john", 34.435});
  std::cout << payRole("john", 124) << std::endl;;
  return 0;
}

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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog