A company pays its employees as managers (who recieve a fixed weekly salary), hourly workers (who recieve a fixed hourly wage for up to the first 40 hours they work and "time- and a half"-1.5 times their hourly wage-for overtime hours worked), commission workes (who recieve \$250 plus 5.7% of their gross weekly sales), or pieceworkers (who recieve a fixed amount of money per item for each of hte items they produce-each pieceworker in this company works on only one type of item).

Can anyone help me out with the source code to calculate the weekly pay for each employee. there is no number of employees in advance. each type of employee has its own pay code managers have paycode , hourly workers have pay code 2, commission workers have code 3 and pieceworkers have code 4.

I need to use a switch to compute each employees pay according to that employees paycode. within the switch, i need to prompt the user (i.e...the payroll clerk) to enter the appropriate facts it needs to calculate each employee's pay according to that employee's paycode.

## All 5 Replies

- What information about each employee is needed in order to compute the salary?

- How are different types of employees paid differently?

- How would you normally compute salary with time and a half (don't think in terms of programming)?

- How is the "paycode" used to determine how an employee gets paid?

- What does a switch statement do? How will it be useful here?

Try to answer these questions and then get back to us. I'm sure once you try to figure out the answers to these questions everything else will fall into place.

Break the assignment up into pieces. Separate it into questions like this, for example?

If you're still having problems even after you've tried to answer these questions, come back and I'll help you.

A week ago, I wouldn't have known how easy this program could be written with PHP. :)

All I would need to know are the pay codes....the rest would be interactive.

In C I would put the switch inside a while loop for continued interactivity. The switch would call functions for each code and return true if completed correctly. And the last case for a bad pay code would output a bad pay code statement and set the completed variable to false. After the switch is exited the competed variable would determine if the program outputs a general error statement. Then ask if the user would like to enter another pay code. If not, exit while and then exit program. Ha.

Of course the first time the program asks for a pay code would be before the while loop.

I guess in C++ you would create a Pay code class?

fastcarz3:

Yet again you post a homework question and make no attempt to answer it yourself, probably because you don't know how to get started. Take a look at the reply I gave to your question a few days back, which gave you an approach to problem solving. It will help you with this problem and the next one you're going to post, and the one after that, and ...

I agree with Bob. Show that you've tried to do the problem. List some code if you have tried it or pseudocode. If you can't come up with even pseudocode, you'll make us wonder why you're attempting to program anything in the first place. You don't even list a possible solution or any sort of algorithm to solve it. I guess that shows what kind of person you are.

We are very happy to help anyone, at least I am. But helping someone takes time. Show us some consideration by at least making an attempt.

My other post on this homework stuff pretty much sums up how I feel.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.