Write a class sales (Salesmam_Name, Product_name, Sales_Quantity, Target). Each salesman deals with a separate product and is assigned a target for a month. At the end of the month his monthly sales is compared with target and commission is calculated as follows: • If Sales_Quantity > target then commission is 25% of extra sales made + 10% of target • If Sales_Quantity ==target then commission is 10% of target. • Otherwise commission is zero Display the salesman information along with commission obtained. (Use array of objects)

//Note: If you are not using Borland or Turbo C then add the following line after header files :
//using namespace std;

#include<conio.h>
#include<iostream.h>
class sales
{
char snm[10],pnm[10]; //snm=salesman name , pnm=product name
        float q,t,com; //q=quantity , t=target , com=commision
public:
   void accept()
   {
    cout<<"\nEnter salesman name: ";
      cin>>snm;
      cout<<"\nEnter product name: ";
      cin>>pnm;
      cout<<"\nEnter target: ";
      cin>>t;
   }
   void cal()
   {
      cout<<"\nHow many sales saleman does : ";
      cin>>q;
      if(q>t)
      {
          q=q-t;
          com=(0.25*q)+(0.1*t);
      }
      else
          if(q==t)
          {
              com=(0.1*t);
          }
   }
   void dis()
   {
    cout<<"\nsalesman name : "<<snm<<"\nproduct name : "<<pnm<<"\ncommission of salesman  : "<<com;
   }
};
int main()
{
   int i,n;
   cout<<"\nEnter How many salesman information you want to enter:- ";
   cin>>n;
   sales s[20]; //array of object
   for(i=0;i<n;i++)
   {
       s[i].accept();
       s[i].cal();
   }
    for(i=0;i<n;i++)
        s[i].dis();
   getch();
   return(0);
}

0 Comments