Click here to Skip to main content
15,881,715 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
Question 2: Classes - Payroll System (Employee)

You are to write a console application prototype for the Holiday Park’s new payroll system.

In this program you are to add and code a class called Employee.

The class will include:
• Three fields (instance variables) for the Employee – the employee name, annual gross salary and the tax rate.
• A constructor with no parameters, which displays the message “Employee record created”
• Three Get methods for each of the Employee fields.
• Three Set methods for each the Employee fields.
• A CalcNet method to calculate and return the net salary.
The net salary is the gross salary less tax (the tax is calculated using the tax rate and gross salary).


In the main method of the program you are to:
• Display an intro/welcome/information message
• Create an object of the Employee class, which should display the correct message saying an employee record has been created.
• Prompt the user for and obtain the employee’s name, annual gross salary and the tax rate.
• Display (with suitable headings) the values of each of the instance variables (name, gross salary and tax rate).
• Using the CalcNet method, display (with suitable headings) the employee’s net salary.

What I have tried:

i got stuck at the last question
Posted
Updated 28-Oct-18 15:38pm

1 solution

A clue for you, but we dont' do homework here:
C++
netSalary = grossSalary * (1 - taxRate);
(assuming tax rate is given as something like '0.33'.

p.s. - If you post the code where you get stuck at, we would be glad to give more pointers.
 
Share this answer
 
v2
Comments
BillWoodruff 29-Oct-18 3:39am    
My vote of #1: a code fragment with untyped variables in reply to an OP who doesn't even take the time to show any code, or be specific, along with saying, in effect, I won't help you, is not a solution.

Yes, I know that others here constantly post as solutions a lecture of one form or another. But, those who do that are most often people who have made incredible contributions to CodeProject over many years.

fyi: I don't think anyone should be posting this type of reply as a solution.

@OriginalGriff
Richard MacCutchan 29-Oct-18 4:56am    
The reason we post as a solution is to take it off the unanswered list. That way people can focus on questions that require genuine assistance, rather than “please do my work for me”.
BillWoodruff 29-Oct-18 5:05am    
Hi Richard, Yes, I am aware of that, and I think it's a serious flaw in the site design. As down-votes pile-up on the question, doesn't that trigger removal ?
Richard MacCutchan 29-Oct-18 16:02pm    
"No, downvotes do not have any material effect. But the actual message may have a positive one."

Richard, aren't questions removed when 3 or more people vote them #1 ?

"I do appreciate your concerns but doing people’s homework for them really does not help them get on in the world."

I can't make sense of what you intend by saying this: I did not post a solution on this thread.

thanks, Bill
David O'Neil 29-Oct-18 11:46am    
"I don't care. They didn't give enough of a sh*t to ask for pointed help, so they got what they got, to paraphrase John Simmons in a way."

If this describes your opinion of the question, then why did you post anything ?

I believe you intended to be helpful.

I am raising my vote to a #3 because I don't think it's fair to apply a double-standard here, when part of the problem is the way the site works, and others have very high rep levels.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900