/*Problem 7 : Write a C++ program to process the sales activity for 20 salesman. Each salesman deals in separate product and is assigned an annual target. At the end of the month, his monthly sales is added into the salestilldate. At the end of the year, his commission is calculated as follows: if sales made is more than target then the commission is 25% of the extra sales made +10 % of the target if sales made is equal to the target then the commission is 10% of the target. Otherwise commission is zero.
*/
//Solution
#include<iostream.h>
#include<conio.h>
class Sales
{
int productno;
int target;
float salestilldate;
int months; // no of months whose details have been recoredd
float commission;
char performance(void);
public :
Sales()
{
productno = 0;
target = 0;
salestilldate=0;
commission=0;
months=0;
}
// constructor
void init(void);
void addsales();
float calcomm(void);
void display(void);
~Sales() //destructor
{
}
}; // class Sales definition ends
char Sales :: performance(void)
{
char ch;
if(salestilldate>target)
ch='E';
else if(salestilldate==target)
ch='G';
else
ch='P';
return ch;
}
void Sales :: init()
{
cout<<"\nEnter product no:";
cin>>productno;
cout<<"\nEnter Annual target:";
cin>>target;
cout<<"\n";
}
void Sales :: addsales()
{
months++;
if(months>12)
cout<<"Yearly Details full..! No more sales can be entered for this year.\n";
else
{
cout<<"\nEnter sales for month"<<months<<":";
float sales;
cin>>sales;
salestilldate +=sales;
cout<<endl;
}
return;
}
void Sales :: display(void)
{
cout<<"\nProduct no :"<<productno;
cout<<"\nAnnual Target :"<<target;
cout<<"\nSales till Date :"<<salestilldate;
cout<<"\nCommission :"<<commission;
cout<<"\n";
}
float Sales :: calcomm(void)
{
if(months==0)
{
cout<<"No details have been entered till date !\n";
cout<<"So, commission cannot be calculated\n";
}
else if(months<12)
{
cout<<"Yearly details not full.\n";
cout<<"Do you still want to calculate the commission?(y/n)..";
char ans;
cin>>ans;
if(ans=='n'|| ans=='N')
goto lb1;
}
{
char ch = performance();
float comm=0.0;
if(ch=='E')
comm=(salestilldate-target)*0.25+target*0.10;
else if(ch=='G')
comm=target*0.10;
commission = comm;
cout<<"Calculated commission is :"<<comm<<endl;
return comm;
}
lb1:
}
int main()
{
clrscr();
Sales salesman[20]; // Array to store information for 20 salesman
//Get details about 20 salesman;
for(int i=0; i<20; i++)
{
cout<<"\nEnter details for salesman"<<(i+1)<<"\n";
salesman[i].init();
}
// Display menu
int ch, sno;
do
{
cout<<"\nMain Menu";
cout<<"1. Add monthly sales\n";
cout<<"2. Calculate commission\n";
cout<<"3. Display details\n";
cout<<"4. Exit\n";
cout<<"Enter your choice(1-4):";
cin>>ch;
cout<<"\n";
if(ch>0 && ch <4)
{
cout<<"\nEnter Salesman number:";
cin>>sno;
}
switch(ch)
{
case 1 : salesman[sno-1].addsales();
break;
case 2 :salesman[sno-1].calcomm();
cout<<"\n";
break;
case 3 :salesman[sno-1].display();
break;
case 4 : break;
default : cout<<"\nWrong choice!\n";
};// end of switch
lb1:
}while(ch>0 && ch<4);
return 0;
} // end of main()
|
|

- Write a C + + program the activity for 20 salesman each deals in separate product and is assigned an annual target at the end of the month his monthly sales is adds in to the sale till date at the end of the year his commissions is calculated as follows if sales made is more than target then the commission is 25% of the extra sales made + 10 % of the target if sales made is equal to the target then the commission is 10% of the target otherwise commission is zero.
|
|
| |
|
|
|
|