Click here to Skip to main content
15,868,030 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Q.No.1: A company pays its employees on a weekly basis. The employees are of two types:
1. Salaried Employees 2. Hourly Employees
Salaried employees are paid with a fixed weekly salary, regardless of the number of hours they worked.
Fix week salary
is
2000 / w
Hourly employees are paid by the hour and receive overtime pay for all hours worked in excess of 40 hours. If they work less than 40 hours then their salary will be:
Salary = wage*hours
If they work more than 40 hours their salary will be calculated using the given formula:
Salary = (40*wage) +((hours-40)*wage*1.5)
Where wage per hour will be 400 PKR.
The company wants to implement a C++ program that performs its payroll calculations. You are required to write C++ program to implement the above mentioned concept using function overloading.
Sample output
Please enter employee status
Hourly Employee
Please enter work hours:
:
30
Your total salary is
12000
Following class diagram can help you to understand the class structure
Class Employee
Salaried Employees Hourly Employees Working Hours wage Salary
+Comput_salay()

What I have tried:

I've tried many ways but can't figure out and also searched on net ... finally last hope here
Posted
Updated 26-Dec-21 22:58pm
v2

Innam Afridi wrote:
don't know how to code.
That's a problem. This site assumes that you know how to code, and have at least attempted to try to solve the problem. If you don't know how to code, then its time for you to drop this course. Its not for you. You must have had at least one semester of classes, as this is not an assignment for beginners, and if you don't know how to even begin to code by now, then you're obviously not suited to being a software developer.
 
Share this answer
 
v2
Comments
Innam Afridi 26-Dec-21 16:04pm    
No , I tried it in many ways but can't made it to work... so I thought maybe someone could help me... By the way its my 2nd sem and at 1st I learnt C and I've focused on python...So can you please help me in it :)
And I know how to code... I was hospitalized due to covid so did'nt took the lectures
k5054 26-Dec-21 16:28pm    
Help we can do. Complete assignments we will not. I'm sorry you were in hospital. You should talk to your Professor and or student services. You'll not be alone in this. The school/uni you are attending probably has policies regarding prolonged absences due to health reasons - particularly at the moment with the pandemic.
But as to help, you'd need to show us your work, and give some details about what's happening (or not happening), with your code. But don't go dumping hundreds of lines of code on us. Try to break down the problems you're having into something small and concise.
If you can do Python, and understand Python objects, you've got a start. Start with creating a class for an employee, then derive an Hourly and Salaried employee from that. But you're going to have to do the heavy lifting. We'll help when you get stuck. But none of the regulars here will do your assignment for you
Innam Afridi 26-Dec-21 16:32pm    
I just need The implemented form of hourly and salaried employee... just that 4 to 6 lines of code... The rest I will do
k5054 26-Dec-21 17:17pm    
Without a base class to work from, how do you expect anyone to do anything?

Anything provided on the basis of this request is highly unlikely to integrate with any work that you've done. In addition, we have no knowledge of what topics you've covered in class. If we were to supply a template class using lambda expressions, for example, and those are topics you have not yet covered, your instructor might think that either you're a very advance student, or far more likely, guilty of plagiarism.

Maybe what you're trying to ask is how to derive a class from a base class? If so, see here: https://en.cppreference.com/w/cpp/language/derived_class If that page doesn't make much sense to you, then either that's way ahead of where you've got to in class or, more likely, you really need to speak with your Professor or Student Services and work out a way to get caught up.

Whatever you decide to do, it seems unlikely that you're going to be able to submit your assignment on time.
Start with some Learn C++ tutorial to learn the language and think over your task. Best is to make some sketch about all functions and members.
You may end up with an Employee class which has a boolean for hourly pay, so you can use an if-else clause like:

C++
int Employee::getSalary() {
 if( isHourlyPaid ) {
  return hours * hourlyWage;
 } else {
  return weeklyFixum;
 }
}
Or you create a base class Employee and child classes for every type.
 
Share this answer
 
Comments
Innam Afridi 27-Dec-21 5:11am    
Thanks Brother very helpful...
Can You help me little more in it?
Innam Afridi 27-Dec-21 5:26am    
Brother If u don't mind can you please write a code for me .. I will be grateful to you//

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