Question

In: Computer Science

Create an Employee class having the following functions and print the final salary in c++ program....

Create an Employee class having the following functions and print
the final salary in c++ program.
- getInfo; which takes the salary, number of hours of work per day
of employee as parameters
- AddSal; which adds $10 to the salary of the employee if it is less
than $500.
- AddWork; which adds $5 to the salary of the employee if the
number of hours of work per day is more than 6 hours.

Solutions

Expert Solution

Here is the Employee class in C++

=============================================================


class Employee{
   private:
   double hours;
   double salary;
   public:
       void getInfo(double hrs, double sal);
       void print() const;
       void AddSal();
       void AddWork();
};


void Employee::getInfo(double hrs, double sal){
   salary = sal;
   hours =hrs;
}
void Employee::print() const{
   cout<<"Employee Salary $"<<salary
       <<", Hours: "<<hours<<endl;
}
void Employee::AddSal(){
   if(salary<500) salary+=10;
}
void Employee::AddWork(){
  
   if(hours<6) salary += 5;
}

=============================================================

// BELOW IS THE COMPLETE C++ PROGRAM

#include<iostream>
#include<iomanip>
using namespace std;

class Employee{
   private:
   double hours;
   double salary;
   public:
       void getInfo(double hrs, double sal);
       void print() const;
       void AddSal();
       void AddWork();
};


void Employee::getInfo(double hrs, double sal){
   salary = sal;
   hours =hrs;
}
void Employee::print() const{
   cout<<"Employee Salary $"<<salary
       <<", Hours: "<<hours<<endl;
}
void Employee::AddSal(){
   if(salary<500) salary+=10;
}
void Employee::AddWork(){
  
   if(hours<6) salary += 5;
}

int main(){

   Employee e;
   e.getInfo(5,400);
   e.print();
   e.AddSal(); cout<<"Invoking AddSal()\n";
   e.print();
   e.AddWork();cout<<"Invoking AddWork()\n";
   e.print();

   return 0;
}

=============================================================


Related Solutions

write a C++ program to CREATE A CLASS EMPLOYEE WITH YOUR CHOICE OF ATTRIBUTES AND FUNCTIONS...
write a C++ program to CREATE A CLASS EMPLOYEE WITH YOUR CHOICE OF ATTRIBUTES AND FUNCTIONS COVERING THE FOLLOWING POINTS: 1) COUNTING NUMBER OF OBJECTS CREATED ( NO OBJECT ARRAY TO BE USED) USING ROLE OF STATIC MEMBER 2) SHOWING THE VALID INVALID STATEMENTS IN CASE OF STATIC MEMBER WITH NON STATIC MEMBER FUNCTION, NON STATIC MEMBERS OF CLASS WITH STATIC MEMBER FUNCTION, BOTH STATIC. SHOW THE ERRORS WHERE STATEMENTS ARE INVALID. 3) CALL OF STATIC MEMBER FUNCTION, DECLARATION OF...
Write in C++ language. (Employee Record): Create a class named 'Staff' having the following members: Data...
Write in C++ language. (Employee Record): Create a class named 'Staff' having the following members: Data members - Id – Name - Phone number – Address - AgeIt also has a function named 'printSalary' which prints the salary of the staff.Two classes 'Employee' and 'Officer' inherits the 'Staff' class. The 'Employee' and 'Officer' classes have data members 'Top Skill' and 'department' respectively. Now, assign name, age, phone number, address and salary to an employee and a officer by making an...
(C++) Follow the template given to calculate and print the monthly salary of an employee. We...
(C++) Follow the template given to calculate and print the monthly salary of an employee. We assume the employee works for 50 weeks during the year with an hourly rate of $25. Your program should ask the user the workHoursPerWeek. If it's over 40, then the excess hours (i.e., workHoursPerWeek over 40) are paid with 20% overtime rate. Note: just print out the monthly salary. Example: If I work for 45 hours with a rate of $30/hr, then my weekly...
Create a class called employee which has the following instance variables: Employee ID number Salary Years...
Create a class called employee which has the following instance variables: Employee ID number Salary Years at the company Your class should have the following methods: New employee which reads in an employee’s ID number, salary and years of service Anniversary which will up the years of service by 1 You got a raise which will read in how much the raise was (a percent) and then calculate the new salary You get a bonus which gives a yearly bonus...
Create a UEmployee class that contains member variables for the university employee name and salary. The...
Create a UEmployee class that contains member variables for the university employee name and salary. The UEmployee class should contain member methods for returning the employee name and salary. Create Faculty and Staff classes that inherit the UEmployee class. The Faculty class should include members for storing and returning the department name. The Staff class should include members for storing and returning the job title. Write a runner program that creates one instance of each class and prints all of...
********************C# C# C#******************** Part A: Create a project with a Program class and write the following...
********************C# C# C#******************** Part A: Create a project with a Program class and write the following two methods(headers provided) as described below: 1. A Method, public static int InputValue(int min, int max), to input an integer number that is between (inclusive) the range of a lower bound and an upper bound. The method should accept the lower bound and the upper bound as two parameters and allow users to re-enter the number if the number is not in the range...
Create a c++ program to compute the product of two integers. call create the following functions:...
Create a c++ program to compute the product of two integers. call create the following functions: 1. getNum - to accept only positive numbers && will call computeProd. 2.computeProd - to compute the product of the numbers & will call the function displayProduct. 3. displayProduct - to display the product. Call the function getNum in the main function. Compute the product w/o using the multiplication operator(*). using #include <iostream> only
1)  Create a UEmployee class that contains member variables for the university employee name and salary. The...
1)  Create a UEmployee class that contains member variables for the university employee name and salary. The UEmployee class should contain member methods for returning the employee name and salary. Create Faculty and Staff classes that inherit the UEmployee class. The Faculty class should include members for storing and returning the department name. The Staff class should include members for storing and returning the job title. Write a runner program that creates one instance of each class and prints all of...
Create a C# Application. Create a class object called “Employee” which includes the following private variables:...
Create a C# Application. Create a class object called “Employee” which includes the following private variables: firstN lastN idNum wage: holds how much the person makes per hour weekHrsWkd: holds how many total hours the person worked each week regHrsAmt: initialize to a fixed amount of 40 using constructor. regPay otPay After going over the regular hours, the employee gets 1.5x the wage for each additional hour worked. Methods: constructor properties CalcPay(): Calculate the regular pay and overtime pay. Create...
In c++ use bool functions to create and print a truth table for disconjunction and negation...
In c++ use bool functions to create and print a truth table for disconjunction and negation functionality and use it to print the truth table for equation pv~p.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT