C++ LAB

PROGRAM 1 PROGRAM 2 PROGRAM 3 PROGRAM 4 PROGRAM 5 PROGRAM 6 PROGRAM 7

PART- B

PROGRAM 1 PROGRAM 2 PROGRAM 3 PROGRAM 4 PROGRAM 5 PROGRAM 6 PROGRAM 7 PROGRAM 8

old

PROGRAM 8 PROGRAM 9 PROGRAM 10 PROGRAM 11 PROGRAM 12 PROGRAM 13 PROGRAM 14 . . .

write a c++ program to calculate family income using friend function

 
#include < iostream >
#include < iomanip >
using namespace std;

class Family{
 
private:
	 string name[10] ;
	 string relation[10];
	 int salary[10];
  
public :
 static int count;
   static double Total;
	 void getdetails();
    void display ();
   friend void  getTotal(Family item);  
};


int Family :: count=0;
double Family :: Total=0;
void Family :: getdetails(){

cout << "Enter    Name: ";
    cin >> name[count];
    cout << "\n";

	cout << "Enter  relation: ";
    cin >> relation[count];
    cout << "\n";

	cout << "Enter salary: ";
    cin >> salary[count];
    cout << "\n";
count++;
}

inline void Family :: display (){
for (int i = 0; i < count; i++)
        {
cout << "    Name: " << name[i]<< endl;
cout << "  relation: " << relation[i]<< endl;
cout << "  salary: " << salary[i]<< endl;
	}
}


 
void   getTotal(Family item)
{
int tot=0;
for (int i = 0; i < Family:: count; i++)
        {
		tot=tot+item.salary[i];
 
}
cout << "Enter  Total cost: " << tot<< endl;
}

 
int main()
{
     
 	Family item;
    int numItems = 0;

    //number of items
    cout << "Enter TOtal number Family memders  : ";
    cin >> numItems;
    cout << "\n";
    
         
 
    for (int i = 0; i < numItems; ++i)
    {
      item.getdetails();

     }
 
 	item.display ();
	 getTotal(item);
 


return 0;
}