Concept explainers
Write a
A member variable of type string that contains the administrator’s title (such as Director or Vice President).
A member variable of type string that contains the company area of responsibility (such as Production, Accounting, or Personnel).
A member variable of type string that contains the name of this administrator’s immediate supervisor.
A protected: member variable of type double that holds the administrator’s annual salary. It is possible for you to use the existing salary member if you did the change recommended earlier.
A member function called setSupervisor, which changes the supervisor name.
A member function for reading in an administrator’s data from the keyboard.
A member function called print, which outputs the object’s data to the screen.
An overloading of the member function printCheck() with appropriate notations on the check.
Salaried Employee
Program Plan:
administrator.h:
- Include required header files.
- Create a namespace.
- Declare a class “Administrator”.
- Inside the “protected” access specifier,
- Declare a variable to hold the salary amount.
- Inside the “public” access specifier,
- Declare the constructors.
- Declare the member functions.
- Inside the “private” access specifier,
- Declare the variables to store the title, responsibility, and name of the supervisor.
- Inside the “protected” access specifier,
- Declare a class “Administrator”.
administrator.cpp:
- Include required header files.
- Create a namespace.
- Declare constructors.
- Set the supervisor name.
- Give function definition for “readData ()”.
- Get the title, responsibility and supervisor name from the user.
- Give function definition for “print ()”.
- Print the details like name, responsibility and supervisor name.
- Give function definition for “printCheck ()”.
- Call the function “setNetPay ()” to set the amount.
- Print the name using the function “getName ()”.
- Print the amount using the function “getNetPay ()”.
- Print the employee number using the function “getSSN ()”.
salariedemployee.h:
- Include required header files.
- Create a namespace.
- Declare a class “SalariedEmployee”.
- Inside “public” access specifier,
- Declare default and parameterized constructor.
- Declare the function “getSalary ()”, and “setSalary ()”.
- Inside “protected” access specifier,
- Declare a variable “salary”.
- Inside “public” access specifier,
- Declare a class “SalariedEmployee”.
salariedemployee.cpp:
- Include required header files.
- Create a namespace.
- Instantiate the constructors.
- Give mutator and accessor functions to set and get the salary amount respectively.
employee.h:
- Include required header files.
- Create a namespace.
- Inside the “public” access specifier.
- Declare the default and parameterized constructor.
- Declare the functions.
- Inside the “private” access specifier.
- Declare required variables like “name”, “ssn”, and “netPay”.
- Inside the “public” access specifier.
employee.cpp:
- Include required header files.
- Create a namespace.
- Instantiate the constructors.
- Give mutator and accessor functions to set and get the name, employee number, and net pay.
- Give function to print the check.
main.cpp:
- Include required header files.
- Declare the “main ()” function.
- Create an object for “Administrator” class.
- Call the function “readData ()”, “print ()”, and “printCheck ()” using the object.
The below program demonstrates the creation of “Administrator” class with the required given constraints.
Explanation of Solution
Program:
administrator.h:
//Include required header files
#ifndef ADMINISTRATOR_H
#define ADMINISTRATOR_H
#include <string>
#include "salariedemployee.h"
using namespace std;
//Create a namespace
namespace SEmployees
{
//Declare a class
class Administrator : public SalariedEmployee
{
//Access specifier
protected:
//Declare a variable
double theAnnualSalary;
//Access specifier
public:
//Constructors
Administrator();
Administrator(const string& theName, const string& theSsn, double theAnnualSalary);
//Declare the member functions
void setSupervisor(const string& newSupervisorName);
void readData();
void print();
void printCheck();
//Access specifier
private:
//Declare required variables
string adminTitle;
string areaOfResponsibility;
string supervisorName;
};
}
#endif
administrator.cpp:
//Include required header files
#include <string>
#include <iostream>
#include "administrator.h"
using namespace std;
//Create a namespace
namespace SEmployees
{
//Constructor
Administrator::Administrator() : SalariedEmployee(), adminTitle("No title yet"),areaOfResponsibility("No responsibility yet"), supervisorName("No supervisor yet"){}
//Constructor
Administrator::Administrator(const string& theName, const string& theSsn,double theAnnualSalary): SalariedEmployee(theName, theSsn, theAnnualSalary), adminTitle("No title yet"), areaOfResponsibility("No responsibility yet"), supervisorName("No supervisor yet"){}
//Function to set supervisor name
void Administrator::setSupervisor(const string& newSupervisorName)
{
//Set the name
supervisorName = newSupervisorName;
}
//Function to get the information
void Administrator::readData()
{
//Print the statement
cout << "Enter the details of the administrator " << getName() << endl;
//Ge the title
cout << " Enter the administrator's title: ";
getline(cin, adminTitle);
//Get the area of responsibility
cout << " Enter the company area of responsibility: ";
getline(cin, areaOfResponsibility);
//Get the name of supervisor
cout << " Enter the name of this administrator's immediate supervisor: ";
getline(cin, supervisorName);
}
//Function to print information
void Administrator::print()
{
//Print the statement
cout << "\nDetails of the administrator..." << endl;
//Print the name
cout << "Administrator's name: " << getName() << endl;
//Print the title
cout << "Administrator's title: " << adminTitle << endl;
//Print the responsibility
cout << "Area of responsibility: " << areaOfResponsibility << endl;
//Print the supervisor name
cout << "Immediate supervisor's name: " << supervisorName << endl;
}
//Function to print the check
void Administrator::printCheck()
{
//Print the statement
cout << "\nPay check..." << endl;
//Call the function
setNetPay(salary);
//Print the statements
cout << "\n_______________________________________________\n";
//Print the name
cout << "Pay to the order of " << getName() << endl;
//Print the amount
cout << "The sum of $" << getNetPay();
cout << "\n_______________________________________________\n";
cout << "Check Stub NOT NEGOTIABLE \n";
//Print the employee number
cout << "Employee Number: " << getSSN() << endl;
//Print the salary
cout << "Salaried Employee (Administrator). Regular Pay: $" << salary;
cout << "\n_______________________________________________\n";
}
}
salariedemployee.h:
//Include required header files
#ifndef SALARIEDEMPLOYEE_H
#define SALARIEDEMPLOYEE_H
#include <string>
#include "employee.h"
using namespace std;
//Create a namespace
namespace SEmployees
{
//Declare a class
class SalariedEmployee : public Employee
{
//Access specifier
public:
//Default constructor
SalariedEmployee( );
//Parameterized constructor
SalariedEmployee (string theName, string theSSN,double theWeeklySalary);
//Function declarations
double getSalary( ) const;
void setSalary(double newSalary);
//Access specifier
protected:
//Declare a variable
double salary;
};
}
#endif
salariedemployee.cpp:
//Include required header files
#include <iostream>
#include <string>
#include "salariedemployee.h"
using namespace std;
//Create a namespace
namespace SEmployees
{
//Constructors
SalariedEmployee::SalariedEmployee( ) : Employee( ), salary(0){}
SalariedEmployee::SalariedEmployee(string theName, string theNumber,double theWeeklySalary): Employee(theName, theNumber), salary(theWeeklySalary){}
//Accessor function to get the salary
double SalariedEmployee::getSalary( ) const
{
//Return the amount
return salary;
}
//Mutator function to set the salary
void SalariedEmployee::setSalary(double newSalary)
{
//Set the amount
salary = newSalary;
}
}
employee.h:
//Include required header files
#ifndef EMPLOYEE_H
#define EMPLOYEE_H
#include <string>
using namespace std;
//Create a namespace
namespace SEmployees
{
//Declare a class
class Employee
{
//Access specifier
public:
//Declare a default constructor
Employee( );
//Declare the parameterized constructor
Employee(string theName, string theSSN);
//Declare the functions
string getName( ) const;
string getSSN( ) const;
double getNetPay( ) const;
void setName(string newName);
void setSSN(string newSSN);
void setNetPay(double newNetPay);
void printCheck( ) const;
//Access specifier
private:
//Declare required variables
string name;
string ssn;
double netPay;
};
}
#endif
employee.cpp:
//Include required header files
#include <string>
#include <cstdlib>
#include <iostream>
#include "employee.h"
using namespace std;
//Create a namespace
namespace SEmployees
{
//Constructors
Employee::Employee( ) : name("No name yet"), ssn("No number yet"), netPay(0){}
Employee::Employee(string theName, string theNumber): name(theName), ssn(theNumber), netPay(0){}
//Accessor function to get a name
string Employee::getName( ) const
{
//Return the name
return name;
}
//Accessor function to get the number
string Employee::getSSN( ) const
{
//Return the number
return ssn;
}
//Accessor function to get the pay
double Employee::getNetPay( ) const
{
//Return the pay
return netPay;
}
//Mutator function to set the name
void Employee::setName(string newName)
{
//Set the name
name = newName;
}
//Mutator function to set the number
void Employee::setSSN(string newSSN)
{
//Set the number
ssn = newSSN;
}
//Mutator function to set the pay
void Employee::setNetPay (double newNetPay)
{
//Set the pay
netPay = newNetPay;
}
//Function to print the check
void Employee::printCheck() const
{
//Print the statements.
cout << "\nERROR: printCheck FUNCTION CALLED FOR AN \n"<< "UNDIFFERENTIATED EMPLOYEE. Aborting the program.\n"<< "Check with the author of the program about this bug.\n";
exit(1);
}
}
main.cpp:
//Include required header files
#include <iostream>
#include "administrator.h"
//Create namespace
using SEmployees::Administrator;
//Main function
int main()
{
//Add details
Administrator admin("Mr. John Smith", "963-85-2741", 10000.00);
//Call the function to read information
admin.readData();
//Call the function to print
admin.print();
//Call the function to print the check
admin.printCheck();
//Return the statement
return 0;
}
Output:
Enter the details of the administrator Mr. John Smith
Enter the administrator's title: Director
Enter the company area of responsibility: Personnel
Enter the name of this administrator's immediate supervisor: Mr. Adams
Details of the administrator...
Administrator's name: Mr. John Smith
Administrator's title: Director
Area of responsibility: Personnel
Immediate supervisor's name: Mr. Adams
Pay check...
_______________________________________________
Pay to the order of Mr. John Smith
The sum of $10000
_______________________________________________
Check Stub NOT NEGOTIABLE
Employee Number: 963-85-2741
Salaried Employee (Administrator). Regular Pay: $10000
_______________________________________________
Want to see more full solutions like this?
Chapter 15 Solutions
Problem Solving with C++ (10th Edition)
Additional Engineering Textbook Solutions
SURVEY OF OPERATING SYSTEMS
Starting Out With Visual Basic (8th Edition)
Java: An Introduction to Problem Solving and Programming (8th Edition)
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Database Concepts (8th Edition)
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
- 1. Complete the routing table for R2 as per the table shown below when implementing RIP routing Protocol? (14 marks) 195.2.4.0 130.10.0.0 195.2.4.1 m1 130.10.0.2 mo R2 R3 130.10.0.1 195.2.5.1 195.2.5.0 195.2.5.2 195.2.6.1 195.2.6.0 m2 130.11.0.0 130.11.0.2 205.5.5.0 205.5.5.1 R4 130.11.0.1 205.5.6.1 205.5.6.0arrow_forwardAnalyze the charts and introduce each charts by describing each. Identify the patterns in the given data. And determine how are the data points are related. Refer to the raw data (table):arrow_forward3A) Generate a hash table for the following values: 11, 9, 6, 28, 19, 46, 34, 14. Assume the table size is 9 and the primary hash function is h(k) = k % 9. i) Hash table using quadratic probing ii) Hash table with a secondary hash function of h2(k) = 7- (k%7) 3B) Demonstrate with a suitable example, any three possible ways to remove the keys and yet maintaining the properties of a B-Tree. 3C) Differentiate between Greedy and Dynamic Programming.arrow_forward
- What are the charts (with their title name) that could be use to illustrate the data? Please give picture examples.arrow_forwardA design for a synchronous divide-by-six Gray counter isrequired which meets the following specification.The system has 2 inputs, PAUSE and SKIP:• While PAUSE and SKIP are not asserted (logic 0), thecounter continually loops through the Gray coded binarysequence {0002, 0012, 0112, 0102, 1102, 1112}.• If PAUSE is asserted (logic 1) when the counter is onnumber 0102, it stays here until it becomes unasserted (atwhich point it continues counting as before).• While SKIP is asserted (logic 1), the counter misses outodd numbers, i.e. it loops through the sequence {0002,0112, 1102}.The system has 4 outputs, BIT3, BIT2, BIT1, and WAITING:• BIT3, BIT2, and BIT1 are unconditional outputsrepresenting the current number, where BIT3 is the mostsignificant-bit and BIT1 is the least-significant-bit.• An active-high conditional output WAITING should beasserted (logic 1) whenever the counter is paused at 0102.(a) Draw an ASM chart for a synchronous system to providethe functionality described above.(b)…arrow_forwardS A B D FL I C J E G H T K L Figure 1: Search tree 1. Uninformed search algorithms (6 points) Based on the search tree in Figure 1, provide the trace to find a path from the start node S to a goal node T for the following three uninformed search algorithms. When a node has multiple successors, use the left-to-right convention. a. Depth first search (2 points) b. Breadth first search (2 points) c. Iterative deepening search (2 points)arrow_forward
- We want to get an idea of how many tickets we have and what our issues are. Print the ticket ID number, ticket description, ticket priority, ticket status, and, if the information is available, employee first name assigned to it for our records. Include all tickets regardless of whether they have been assigned to an employee or not. Sort it alphabetically by ticket status, and then numerically by ticket ID, with the lower ticket IDs on top.arrow_forwardFigure 1 shows an ASM chart representing the operation of a controller. Stateassignments for each state are indicated in square brackets for [Q1, Q0].Using the ASM design technique:(a) Produce a State Transition Table from the ASM Chart in Figure 1.(b) Extract minimised Boolean expressions from your state transition tablefor Q1, Q0, DISPATCH and REJECT. Show all your working.(c) Implement your design using AND/OR/NOT logic gates and risingedgetriggered D-type Flip Flops. Your answer should include a circuitschematic.arrow_forwardA controller is required for a home security alarm, providing the followingfunctionality. The alarm does nothing while it is disarmed (‘switched off’). It canbe armed (‘switched on’) by entering a PIN on the keypad. Whenever thealarm is armed, it can be disarmed by entering the PIN on the keypad.If motion is detected while the alarm is armed, the siren should sound AND asingle SMS message sent to the police to notify them. Further motion shouldnot result in more messages being sent. If the siren is sounding, it can only bedisarmed by entering the PIN on the keypad. Once the alarm is disarmed, asingle SMS should be sent to the police to notify them.Two (active-high) input signals are provided to the controller:MOTION: Asserted while motion is detected inside the home.PIN: Asserted for a single clock cycle whenever the PIN has beencorrectly entered on the keypad.The controller must provide two (active-high) outputs:SIREN: The siren sounds while this output is asserted.POLICE: One SMS…arrow_forward
- 4G+ Vo) % 1.1. LTE1 : Q B NIS شوز طبي ۱:۱۷ کا A X حاز هذا على إعجاب Mohamed Bashar. MEDICAL SHOE شوز طبي ممول . اقوى عرض بالعراق بلاش سعر القطعة ١٥ الف سعر القطعتين ٢٥ الف سعر 3 قطع ٣٥ الف القياسات : 40-41-42-43-44- افحص وكدر ثم ادفع خدمة التوصيل 5 الف لكافة محافظات العراق ופרסם BNI SH ופרסם DON JU WORLD DON JU MORISO DON JU إرسال رسالة III Messenger التواصل مع شوز طبي تعليق باسم اواب حمیدarrow_forwardA manipulator is identified by the following table of parameters and variables:a. Obtain the transformation matrices between adjacent coordinate frames and calculate the global transformation matrix.arrow_forwardWhich tool takes the 2 provided input datasets and produces the following output dataset? Input 1: Record First Last Output: 1 Enzo Cordova Record 2 Maggie Freelund Input 2: Record Frist Last MI ? First 1 Enzo Last MI Cordova [Null] 2 Maggie Freelund [Null] 3 Jason Wayans T. 4 Ruby Landry [Null] 1 Jason Wayans T. 5 Devonn Unger [Null] 2 Ruby Landry [Null] 6 Bradley Freelund [Null] 3 Devonn Unger [Null] 4 Bradley Freelund [Null] OA. Append Fields O B. Union OC. Join OD. Find Replace Clear selectionarrow_forward
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT