class employee //Line 1
{ //Line 2
public: //Line 3
employee(); //Line 4
employee(string, int, double); //Line 5
employee(int, double); //Line 6
employee(string); //Line 7
void setData(string, int, double); //Line 8
void print() const; //Line 9
void updateSalary(double x); //Line 10
int getNumOfServiceYears() const; //Line 11
double getSalary() const; //Line 12
private: //Line 13
string name; //Line 14
int numOfServiceYears; //Line 15
double salary; //Line 16
};
a. Give the line number containing the constructor that is executed in each of the following declarations:
i. employee tempEmployee;
ii. employee newEmployee("Harry Miller", 0, 25000);
iii. employee oldEmployee("Bill Dunbar", 15, 55000);
b. Write the definition of the constructor in Line 4 so that the instance variables are initialized to " ", 0, and 0.0, respectively.
c. Write the definition of the constructor in Line 5 so that the instance variables are initialized according to the parameters.
d. Write the definition of the constructor in Line 6 so that the instance variable name is initialized to the empty string and the remaining instance variables are initialized according to the parameters.
a. i) Line 4 - employee() - as there are no parameters
ii)Line 5 - employee(string, int, double); - as three parameters are passed in the sequence string,int,double/int
iii)Line 5 - employee(string, int, double); - as three parameters are passed in the sequence string,int,double/int
b. employee() // constructor definition
{
name = " "; //initialize name
numOfServiceYears = 0; // initialize numOfServiceYears
salary = 0.0 ; // initialize salary
}
c.
employee(string str, int years, double sal) // constructor definition
{
name = str; //initialize name
numOfServiceYears = years; // initialize numOfServiceYears
salary = sal ; // initialize salary
}
d.
employee(int years, double sal) //definition of constructor
{
name = ""; //initialize name
numOfServiceYears = years; // initialize numOfServiceYears
salary = sal ; // initialize salary
}
C++
Consider the definition of the following class: (1,2,3, 5,7 clasa productTyp publie productType O productType(int. double, double) productType (atring, int, double, double)s //tine6 productType (atring. atring.atring //Line1 /Line 2 /Line 3 //Line /Line s int, double, double) //Line 7 void set (atring, atring, string. int void print) const double, double) i //Line //tine 9 void setQuantitiesInstock (int x) void updateQuantitiesinstock (int x) int getQuantitiesInstock) const //Line 10 //Line 11 //Line 12 void #etPrice (double x); double getPrice) consti //Line...
Student is a class that has the following instance variables: name (a String), yearInSchool (an int), and gpa (a double). Write a constructor for the Student class that takes parameters for these instance variables as initial values of the variables. (in Java)
c++ only Design a class representing an Employee. The employee would have at least these private fields (Variables): name: string (char array) ID: string (char array) salary: float Type: string (char array) All the variables except for the salary should have their respective setters and getters, and the class should have two constructors, one is the default constructor and the other constructor initializes the name,ID and type of employee with valid user input. The class should have the following additional...
Write a Java class named Employee to meet the
requirements described in the UML Class Diagram below:
Note: Code added in the toString cell are not usually included
in a regular UML class diagram. This was added so you can
understand what I expect from you.
If your code compiles cleanly, is defined correctly and
functions exactly as required, the expected output of your program
will solve the following problem:
“An IT company with four departments and a staff strength...
c++ please need help with this question Consider a class Employee with data members: age(an integer), id (an integer) and salary (a float), and their corresponding member functions as follows: class Employee { private: int age; int id; float salary; public: Employee( ); // default constructor: age=0, id=0, and salary=0 Employee(Employee &x); // copy constructor Employee& operator = (Employee &x); // equal sign operator void setAge(int x); // let age = x...
Answer this in c++ #include <iostream> #include <fstream> #include <string> using namespace std; class Person { public: Person() { setData("unknown-first", "unknown-last"); } Person(string first, string last) { setData(first, last); } void setData(string first, string last) { firstName = first; lastName = last; } void printData() const { cout << "\nName: " << firstName << " " << lastName << endl; } private: string firstName; string lastName; }; class Musician : public Person { public: Musician() { // TODO: set this...
Following is the EmployeeTester class, which creates object of the class Employee and calls the methods of that object. The EmployeeTester class is written to test another class: Employee. You are required to implement the class Employee by: declaring its instance variables: name, age, salary. implementing its constructor. implementing its methods: getEmployeeName(), getEmployeeAge(), getEmployeeSalary(), setEmployeeAge(int empAge), setEmployeeSalary(double empSalary) public class EmployeeTester { public static void main(String args[]) { // Construct an object Employee employeeOne = new Employee("Ahmad Abdullah"); //...
In a project named 'DogApplication', create a class called 'Dog' 1. declare two instance variables in 'Dog' : name (String type) age (int type) 2. declare the constructor for the 'Dog' class that takes two input parameters and uses these input parameters to initialize the instance variables 3. create another class called 'Driver' and inside the main method, declare two variables of type 'Dog' and call them 'myDog' and 'yourDog', then assign two variables to two instance of 'Dog' with...
It must be C++
Chapter 13 Programming Challenge 2: Employee Class.
See instruction: Chapter 13 Programming Challenge 2 Employee
Class.pdf
Program Template:
// Chapter 13, Programming Challenge 2: Employee Class
#include <iostream>
#include <string>
using namespace std;
// Employee Class Declaration
class Employee
{
private:
string name; // Employee's name
int idNumber; // ID number
string department; // Department name
string position; // Employee's position
public:
// TODO: Constructors
// TODO: Accessors
// TODO: Mutators
};
// Constructor #1
Employee::Employee(string...