Question: In C++, Friend Function Question: PLEASE MAKE SURE YOU USE FRIEND FUNCTION ( FUNCTION WITH THE FRIEND KEYWORD). Use your Assignment 1 class or similar
In C++,
Friend Function Question:
PLEASE MAKE SURE YOU USE FRIEND FUNCTION ( FUNCTION WITH THE FRIEND KEYWORD).
Use your Assignment 1 class or similar and declare a function named TAX to be a friend function. Write the TAX function definition to calculate witholding if salary is less than 30000 withold 10 % if salary is 30000 to 50000 withold 15% if salary is more than 50000 withold 20% The amount witheld should be put into new data member TAXWH
NOTE: PLEASE READ THE QUESTION CAREFULLY FIRST AND STAY WITHIN THE CONCEPT OF ASSIGMENT 1 GIVEN BELOW. THANK YOU
// Assingment 1 starts here
#include
using namespace std;
class EMPLOYEE
{
public:
void setName(string n){
name = n;
}
string getName(){
return name;
}
void setID(int i){
ID = i;
}
int getID() {
return ID;
}
void setSalary(float s){
salary = s;
}
float getSalary(){
return salary;
}
private:
string name;
int ID;
float salary;
};
int main(){
EMPLOYEE A1;
string name;
int ID;
float salary;
cout <<"Enter Employee name: ";
cin >> name;
cout <<"Enter 4-Digit Employee ID: ";
cin >> ID;
cout <<"Enter Employee Salary: ";
cin >> salary;
cout < A1.setName(name); A1.setID(ID); A1.setSalary(salary); cout <<"--Details--"< cout<<"Name: "< cout <<"ID: "< cout <<"Salary: $"< return 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
