Click here to Skip to main content
15,312,535 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
#include <iostream>
#include <conio.h>
using namespace std;

class Employee
{
string name;
double hourwork, wage, netsal;
public:

void getEmployee(string &Name, double &hourWork, double &Wage)
{
name = Name;
hourwork = hourWork;
wage = Wage;
netsal = wage * hourwork ;
}

void calculateGrossPay()
{
double ot, sal;
if(hourwork <= 40)
{
sal = hourwork*wage;
}
else
{
sal = 2000;
}
}

void printEmolyeePayment()
{
cout << "Status of Employee : "<< name <<"Salary of Empoloyee : "<<netsal;
}
};

int="" main()
{
="" string="" name;
="" double="" hourwork,="" wage,="" netsal;
="" char="" flag="y" ;

="" grosspay;
="" int="" i="0;

" while(flag="='y')
" {
="" cout="" <<="" "\nenter="" employee="" detail\n";
="" "status="" of="" :="" ";
="" cin="">> name;
cout << "Work Hour Of Employee : ";
cin >> hourwork;
cout << "Rate Per Hour Of Employee : ";
cin >> wage;
cout << netsal;

}
return 0;
}

What I have tried:

First I tried if else but did'nt work and changed the code 6th time still it does not give the result according to the question below:
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()
Hope Someone will help me in this Please
Posted
Updated 27-Dec-21 6:27am
v2

You already posted this question at I have a project on OOP C++ to code a program on salary.[^]. Please do not repost. If you have additional information then please use the Improve question link in the original post, and add the details there.
   
Comments
Innam Afridi 27-Dec-21 8:50am
   
Im sorry.. I did'nt know that...
Innam Afridi 27-Dec-21 8:51am
   
richard brother can you help me in this... I have 4 hours left for submission
Richard MacCutchan 27-Dec-21 8:55am
   
Read the assignment again. There are two types of employees, so you need a base class and two classes that inherit from the base. If you do not understand that part then you are going to struggle with all the rest.
Innam Afridi 27-Dec-21 9:01am
   
Richard Brother.. Only for once Help me in the code... I will be grateful... what O tried is in front of you.. Hope You will re-edit the code for me
Dave Kreskowiak 27-Dec-21 10:59am
   
If by "Help" you mean "write my code for me," that's not going to happen. That's not helping you at all.
Innam Afridi 27-Dec-21 11:07am
   
Please brother I have 2 hours left for submission... You can only re-edit the code for me please I will be grateful to you...Brother Please
\
Dave Kreskowiak 27-Dec-21 11:08am
   
What part of "WE ARE NOT WRITING YOUR CODE FOR YOU" did you not understand?
Quote:
First I tried if else but did'nt work and changed the code 6th time still it does not give the result according to the question
Making random changes isn't going to get you anywhere: you need to sit down and think before you even start to code. Try it manually on paper, and get the "how to do this" bit sorted in you head before you even start reaching for a keyboard.

What you have at the moment looks like you describe: a guess at what to do followed by random hacks to try and get it to the point where you can hand it in.
Quote:
HOPE SOMEONE WILL RE-EDIT IT AND IMPLEMENT IT ACCORDING TO THE NEED
Even if you weren't SHOUTING AT US, that won't happen: While we are more than willing to help those that are stuck, that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.

So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.

If you are having problems getting started at all, then this may help: How to Write Code to Solve a Problem, A Beginner's Guide[^]
   
Comments
Innam Afridi 27-Dec-21 8:56am
   
Brother I'm not shouting... I respect All... Sorry about that and can you tell me how to delete question?
OriginalGriff 27-Dec-21 9:16am
   
https://newrepublic.com/article/117390/netiquette-capitalization-how-caps-became-code-yelling
Innam Afridi 27-Dec-21 9:19am
   
I am really sorry Brother really reall sorry about that... I did'nt know that... Hope you won't mind that
Innam Afridi 27-Dec-21 8:58am
   
Brother Only this and only time help me in the code according to the requirments. Please
OriginalGriff 27-Dec-21 9:20am
   
It wouldn't help you if we did it for you: you would learn nothing, and the next task (which assumes you understood everything from this one) would be commensurately harder. There is also the plagiarism problem: teachers are well aware of sites like this one, and will detect your copy faster that you can copy'n'paste it ...

This isn't a complicated problem; it builds on previous homework and lessons.
So throw away what you have, sit down with a fresh mind and give it a proper try - it'll be a lot quicker than waiting for someone to do it for you, and you should learn something useful from the exercise. Give it a try!
Innam Afridi 27-Dec-21 9:23am
   
I know Brother... Only for once Please... I will understand it and then rebuild it with my own words... But help me this time Brother
Innam Afridi 27-Dec-21 9:38am
   
Only once Brother. I will Be thankful to you,,,
You didnt read the tutorial I advised you. You need to create an instance of the employee and fill its members. Write a member function of the class and use it.

Use the debugger to understand your code.
   

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