Question

In: Computer Science

Please program in C++ Create two classes, HUSBAND (Family Member 1) and WIFE (Family Member 2)....

Please program in C++

Create two classes, HUSBAND (Family Member 1) and WIFE (Family Member 2). Make WIFE as friend class of HUSBAND. The structure of classes are given below.

class WIFE;

class HUSBAND

{

private:

                string Husband_fname;

                string Husband_lname;

                int Husband_income;

public:

                HUSBAND(string f1, string l1, int inc):Husband_fname(f1), Husband_lname(l1), Husband_income(inc);

                HUSBAND();

                {

                //            Default initializations of data members

                }

                int getIncome();

               

};

class WIFE

{

private:

                string Wife_fname;

                string Wife_lname;

                int Wife_income;

                int tax_rate;

public:

                WIFE(string f2, string l2, int inc, int tr) ;

                WIFE()

                {

                                //Default initializations of private data members;

                }

                float calcTax(HUSBAND &f);

               

                float getTaxRate();

               

                int getIncome();

               

};

int main()

{

                HUSBAND obj1("Albert","John",55026);

                WIFE obj2("Mary","Chin",120000,5);

//Task1: Display the tax rate;

// Task2: Display income of HUSBAND;

// Task3: Display income of WIFE;

// Task4: Display total family income;

// Task5: Display total Tax Amount;

                system("pause");

                return 0;

}

Solutions

Expert Solution

#include <iostream>

using namespace std;

class HUSBAND

{

private:

       string Husband_fname;

       string Husband_lname;

       int Husband_income;

       friend class WIFE;

public:

       HUSBAND(string f1, string l1, int inc);

       HUSBAND();

       int getIncome();

};

HUSBAND::HUSBAND(string f1, string l1, int inc):Husband_fname(f1), Husband_lname(l1), Husband_income(inc)

{}

HUSBAND::HUSBAND()

{}

int HUSBAND::getIncome()

{

       return Husband_income;

}

class WIFE

{

private:

       string Wife_fname;

       string Wife_lname;

       int Wife_income;

       int tax_rate;

public:

       WIFE(string f2, string l2, int inc, int tr) ;

       WIFE();

       float calcTax(HUSBAND &f);

       float getTaxRate();

       int getIncome();

};

WIFE::WIFE(string f2, string l2, int inc, int tr) : Wife_fname(f2), Wife_lname(l2), Wife_income(inc), tax_rate(tr)

{}

WIFE::WIFE()

{}

float WIFE::calcTax(HUSBAND &f)

{

       return(((getIncome()+f.getIncome())*getTaxRate())/100);

}

int WIFE::getIncome()

{

       return Wife_income;

}

float WIFE::getTaxRate()

{

       return tax_rate;

}

int main() {

       HUSBAND obj1("Albert","John",55026);

       WIFE obj2("Mary","Chin",120000,5);

       //Task1: Display the tax rate;

       cout<<"Tax Rate : "<<obj2.getTaxRate()<<endl;

       // Task2: Display income of HUSBAND;

       cout<<"Husband Income : "<<obj1.getIncome()<<endl;

       // Task3: Display income of WIFE;

       cout<<"Wife Income : "<<obj2.getIncome()<<endl;

       // Task4: Display total family income;

       cout<<"Total family Income : "<<(obj1.getIncome()+obj2.getIncome())<<endl;

       // Task5: Display total Tax Amount;

       cout<<"Total Tax Amount : "<<obj2.calcTax(obj1)<<endl;

       system("pause");

       return 0;

}

//end of program

Output:


Related Solutions

Write a C++ program to allow the user to: 1. Create two classes. Employee and Departments....
Write a C++ program to allow the user to: 1. Create two classes. Employee and Departments. The Department class will have: DepartmentID, Departmentname, DepartmentHeadName. The Employee class will have employeeID, emploeename, employeesalary, employeeage, employeeDepartmentID. Both of the above classes should have appropriate constructors, accessor methods. 2. Create two arrays . One for Employee with the size 5 and another one for Department with the size 3. Your program should display a menu for the user to do the following: 1....
Create this C++ program using classes 1. Create a file text file with a string on...
Create this C++ program using classes 1. Create a file text file with a string on it 2. Check the frecuency of every letter, number and symbol (including caps) 3. Use heapsort to sort the frecuencys found 4. Use huffman code on the letters, symbols or numbers that have frecuencys I created the file, and the frecuency part but i'm having trouble with the huffman and heapsort implementation.
C++ Assignment 1: Make two classes practice For each of the two classes you will create...
C++ Assignment 1: Make two classes practice For each of the two classes you will create for this assignment, create an *.h and *.cpp file that contains the class definition and the member functions. You will also have a main file 'main.cpp' that obviously contains the main() function, and will instantiate the objects and test them. Class #1 Ideas for class one are WebSite, Shoes, Beer, Book, Song, Movie, TVShow, Computer, Bike, VideoGame, Car, etc Take your chosen class from...
Classes and Objects Write a program that will create two classes; Services and Supplies. Class Services...
Classes and Objects Write a program that will create two classes; Services and Supplies. Class Services should have two private attributes numberOfHours and ratePerHour of type float. Class Supplies should also have two private attributes numberOfItems and pricePerItem of type float. For each class, provide its getter and setter functions, and a constructor that will take the two of its private attributes. Create method calculateSales() for each class that will calculate the cost accrued. For example, the cost accrued for...
Create a moderately complex java program that utilises 2 or more classes. Within these classes: -...
Create a moderately complex java program that utilises 2 or more classes. Within these classes: - have one that defines an exception - have that exception throw(n) in one method and handled in another -has the program continue even if the user inputs incorrect data -be creative/unique in some way
All I need is a general response, please! Phase I: 1. "The combination of husband, wife,...
All I need is a general response, please! Phase I: 1. "The combination of husband, wife, and children that 99.8 percent of people in the United States believe constitutes a family is not representative of 99.8 percent of U.S. families. According to 2010 census data, only 66 percent of children under seventeen years old live in a household with two married parents." Describe what your family unit currently looks like. (Mom, Dad, Brothers, Sisters?) Do you all live with one...
C++ Classes & Objects Create a class named Student that has three private member: string firstName...
C++ Classes & Objects Create a class named Student that has three private member: string firstName string lastName int studentID Write the required mutator and accessor methods/functions (get/set methods) to display or modify the objects. In the 'main' function do the following (1) Create a student object "student1". (2) Use set methods to assign StudentID: 6337130 firstName: Sandy lastName: Santos (3) Display the students detail using get functions in standard output using cout: Sandy Santos 6337130
An insurance company has written two life insurance policies for a husband and wife. Policy 1...
An insurance company has written two life insurance policies for a husband and wife. Policy 1 pays $10,000 to their children if both husband and wife die during this year. Policy 2 pays $100,000 to the surviving spouse if either husband or wife dies during this year. The probability that the husband will die this year is .011. The probability that the wife will die this year is .008. Find the probability that each policy will pay a benefit this...
C++ tree program (please do NOT use struct Node, use classes) Program 1 Implement a Binary...
C++ tree program (please do NOT use struct Node, use classes) Program 1 Implement a Binary tree using an array Program 2 Implement a tree using linked list - pointer Binary Tree Program 3 - Convert program 1 to a template (include screenshots please of output)
C++ tree program (please do NOT use struct Node, use classes) Program 1 Implement a Binary...
C++ tree program (please do NOT use struct Node, use classes) Program 1 Implement a Binary tree using an array Program 2 Implement a tree using linked list - pointer Binary Tree Program 3 - Convert program 1 to a template
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT