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)
- Make the following game user friendly with GUI, with some simple graphics. The GUI should be in another seperate class, with some ImageIcon, and Game class should be added into the pane. The following code works as this: The objective of the player is to escape from this labyrinth. The player starts at the bottom left corner of the labyrinth. He has to get to the top right corner of the labyrinth as fast he can, avoiding a meeting with the evil dragon. The player can move only in four directions: left, right, up or down. There are several escape paths in all labyrinths. The player’s character should be able to moved with the well known WASD keyboard buttons. If the dragon gets to a neighboring field of the player, then the player dies. Because it is dark in the labyrinth, the player can see only the neighboring fields at a distance of 3 units. Cell Class: public class Cell { private boolean isWall; public Cell(boolean isWall) { this.isWall = isWall; } public boolean isWall() { return…arrow_forwardDiscuss the negative and positive impacts or information technology in the context of your society. Provide two references along with with your answerarrow_forwardA cylinder of diameter 10 cm rotates concentrically inside another hollow cylinder of inner diameter 10.1 cm. Both cylinders are 20 cm long and stand with their axis vertical. The annular space is filled with oil. If a torque of 100 kg cm is required to rotate the inner cylinder at 100 rpm, determine the viscosity of oil. Ans. μ= 29.82poisearrow_forward
- Make the following game user friendly with GUI, with some simple graphics The following code works as this: The objective of the player is to escape from this labyrinth. The player starts at the bottom left corner of the labyrinth. He has to get to the top right corner of the labyrinth as fast he can, avoiding a meeting with the evil dragon. The player can move only in four directions: left, right, up or down. There are several escape paths in all labyrinths. The player’s character should be able to moved with the well known WASD keyboard buttons. If the dragon gets to a neighboring field of the player, then the player dies. Because it is dark in the labyrinth, the player can see only the neighboring fields at a distance of 3 units. Cell Class: public class Cell { private boolean isWall; public Cell(boolean isWall) { this.isWall = isWall; } public boolean isWall() { return isWall; } public void setWall(boolean isWall) { this.isWall = isWall; } @Override public String toString() {…arrow_forwardPlease original work What are four of the goals of information lifecycle management think they are most important to data warehousing, Why do you feel this way, how dashboards can be used in the process, and provide a real life example for each. Please cite in text references and add weblinksarrow_forwardThe following is code for a disc golf program written in C++: // player.h #ifndef PLAYER_H #define PLAYER_H #include <string> #include <iostream> class Player { private: std::string courses[20]; // Array of course names int scores[20]; // Array of scores int gameCount; // Number of games played public: Player(); // Constructor void CheckGame(int playerId, const std::string& courseName, int gameScore); void ReportPlayer(int playerId) const; }; #endif // PLAYER_H // player.cpp #include "player.h" #include <iomanip> Player::Player() : gameCount(0) {} void Player::CheckGame(int playerId, const std::string& courseName, int gameScore) { for (int i = 0; i < gameCount; ++i) { if (courses[i] == courseName) { // If course has been played, then check for minimum score if (gameScore < scores[i]) { scores[i] = gameScore; // Update to new minimum…arrow_forward
- In this assignment, you will implement a multi-threaded program (using C/C++) that will check for Prime Numbers and Palindrome Numbers in a range of numbers. Palindrome numbers are numbers that their decimal representation can be read from left to right and from right to left (e.g. 12321, 5995, 1234321). The program will create T worker threads to check for prime and palindrome numbers in the given range (T will be passed to the program with the Linux command line). Each of the threads works on a part of the numbers within the range. Your program should have some global shared variables: • numOfPrimes: which will track the total number of prime numbers found by all threads. numOfPalindroms: which will track the total number of palindrome numbers found by all threads. numOfPalindromic Primes: which will count the numbers that are BOTH prime and palindrome found by all threads. TotalNums: which will count all the processed numbers in the range. In addition, you need to have arrays…arrow_forwardHow do you distinguish between hardware and a software problem? Discuss theprocedure for troubleshooting any hardware or software problem. give one reference with your answer.arrow_forwardYou are asked to explain what a computer virus is and if it can affect computer’shardware or software. How do you protect your computer against virus? give one reference with your answer.arrow_forward
- Distributed Systems: Consistency Models fer to page 45 for problems on data consistency. structions: Compare different consistency models (e.g., strong, eventual, causal) for distributed databases. Evaluate the trade-offs between availability and consistency in a given use case. Propose the most appropriate model for the scenario and explain your reasoning. Link: [https://drive.google.com/file/d/1wKSrun-GlxirS31Z9qoHazb9tC440AZF/view?usp=sharing]arrow_forwardOperating Systems: Deadlock Detection fer to page 25 for problems on deadlock concepts. structions: • Given a system resource allocation graph, determine if a deadlock exists. If a deadlock exists, identify the processes and resources involved. Suggest strategies to prevent or resolve the deadlock and explain their trade-offs. Link: [https://drive.google.com/file/d/1wKSrun-GlxirS31Z9qoHazb9tC440 AZF/view?usp=sharing]arrow_forwardArtificial Intelligence: Heuristic Evaluation fer to page 55 for problems on Al search algorithms. tructions: Given a search problem, propose and evaluate a heuristic function. Compare its performance to other heuristics based on search cost and solution quality. Justify why the chosen heuristic is admissible and/or consistent. Link: [https://drive.google.com/file/d/1wKSrun-GlxirS31Z9qoHazb9tC440 AZF/view?usp=sharing]arrow_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,