In: Computer Science
Write a c++ program for the Sales Department to keep track of the monthly sales of its salespersons. The program shall perform the following tasks:
Sample output:
How many salespersons you want to enter? :2
Enter details of employee
--------------------------
Enter employee No. :10
Enter employee name:Amy Ho
Enter employee phone No. :3134735678
Enter employee office location :Detroit
Enter monthly sales amount : $100000
Enter details of employee
--------------------------
Enter employee No. :20
Enter employee name:Brady Anderson
Enter employee phone No. :5156789876
Enter employee office location :Chicago
Enter monthly sales amount : $95876
The highest monthly sales is : $100000
Congratulations, Amy Ho! You are the top salesperson this month.
The lowest monthly sales is : $95876
Ramp Up, Brady Anderson. Your sales is the lowest this month.
C++ PROGRAM
#include <iostream>
#include <string>
#include <climits>
using namespace std;
class Employees{//class Employees
protected:
long int phone_no;
};
class Sales: public Employees {//class Sales
public:
int emp_no;
string emp_name;
};
class Salesperson: public Sales{//class Salesperson
public:
string location;
int monthly_sales;
void employee_details(){//function employee_details
cout<<"\nEnter Employee number: ";
cin>>emp_no;
cout<<"Enter Employee name: ";
cin.ignore();
getline(cin,emp_name);
cout<<"Enter Employee phone number: ";
cin>>phone_no;
cout<<"Enter Employee office location: ";
cin.ignore();
getline(cin,location);
cout<<"Enter Monthly sales amount: $";
cin>>monthly_sales;
}
};
int main()
{
int i, count, temp;
Salesperson man[50];
cout<<"How many salespersons you want to enter? : ";
cin>>count;
int highest_monthly_sales=INT_MIN;
int lowest_monthly_sales=INT_MAX;
for(i=0;i<count;i++){
cout<<"\nEnter details of employee";
cout<<"\n--------------------------";
man[i].employee_details();
}
for(i=0;i<count;i++){
if(highest_monthly_sales<man[i].monthly_sales){
highest_monthly_sales=man[i].monthly_sales;
temp=i;
}
}
cout<<"\nThe highest monthly sales is :
$"<<highest_monthly_sales;
cout<<"\nCongratulations,
"<<man[temp].emp_name<<"! You are the top salesperson
this month.";
for(i=0;i<count;i++){
if(lowest_monthly_sales>man[i].monthly_sales){
lowest_monthly_sales=man[i].monthly_sales;
temp=i;
}
}
cout<<"\nThe lowest monthly sales is :
$"<<lowest_monthly_sales;
cout<<"\nRamp Up, "<<man[temp].emp_name<<". Your
sales is the lowest this month.";
return 0;
}
OUTPUT