Question

In: Computer Science

Write a c++ program for the Sales Department to keep track of the monthly sales of...

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:

  • Create a base class “Employees” with a protected variable “phone_no”
  • Create a derived class “Sales” from the base class “Employees” with two public variables “emp_no” and “emp_name”
  • Create a second level of derived class “Salesperson” from the derived class “Sales” with two public variables “location” and “monthly_sales”
  • Create a function “employee_details” under the class “Salesperson” for obtaining the following information:
    • Employee number “emp_no”
    • Employee name “emp_name”
    • Employee phone number “phone_no”
    • Employee office location “location”
    • Monthly sales amount “monthly_sales”
  • In the main() function, do the following:
    • Declare variables (int i, count, temp)
    • Create an object of Salesperson (ex. Salesperson man[50])
    • Prompt user to enter the number of salespersons
    • Create a for loop to loop through the number of salespersons to obtain the detailed info of the salesperson calling the “employee_details” function
    • Create a for loop to determine the salesperson with the highest sales
    • Print the results as below:
      • The highest monthly sales is : $100000
      • Congratulations!! Amy Ho! You are the top salesperson this month.
    • Create a for loop to determine the salesperson with the lowest sales
    • Print the results as below:
      • The lowest monthly sales is : $95876
      • Ramp Up, Brady Anderson. Your sales is the lowest this month.

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.

Solutions

Expert Solution

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


Related Solutions

Accounting Program in c++ Write a class to keep track of a balance in a bank...
Accounting Program in c++ Write a class to keep track of a balance in a bank account with a varying annual interest rate. The constructor will set both the balance and the interest rate to some initial values (with defaults of zero). The class should have member functions to change or retrieve the current balance or interest rate. There should also be functions to make a deposit (add to the balance) or withdrawal (subtract from the balance). You should not...
Overview In this assignment, you will write a program to track monthly sales data for a...
Overview In this assignment, you will write a program to track monthly sales data for a small company. Input Input for this program will come from two different disk files. Your program will read from these files by explicitly opening them. The seller file (sellers.txt) consists of an unknown number of records, each representing one sale. Records consist of a last name, a first name, a seller ID, and a sales total. So, for example, the first few records in...
Write a Java program that lets the user keep track of their homemade salsa sales. Use...
Write a Java program that lets the user keep track of their homemade salsa sales. Use 5-element arrays to track the following. The salsa names mild, medium, sweet, hot, and zesty. The number of each type sold. The price of each type of salsa. Show gross amount of money made (before tax). Calculate how much the user owes in sales tax (6% of the amount made). Then display the net profit (after subtracting the tax).
ASSIGNMENT: Write a program to keep track of the total number of bugs collected in a...
ASSIGNMENT: Write a program to keep track of the total number of bugs collected in a 7 day period. Ask the user for the number of bugs collected on each day, and using an accumulator, keep a running total of the number of bugs collected. Display the total number of bugs collected, the count of the number of days, and the average number of bugs collected every day. Create a constant for the number of days the bugs are being...
Using c++ Design a system to keep track of employee data. The system should keep track...
Using c++ Design a system to keep track of employee data. The system should keep track of an employee’s name, ID number and hourly pay rate in a class called Employee. You may also store any additional data you may need, (hint: you need something extra). This data is stored in a file (user selectable) with the id number, hourly pay rate, and the employee’s full name (example): 17 5.25 Daniel Katz 18 6.75 John F. Jones Start your main...
Write a program using c++. Write a program that uses a loop to keep asking the...
Write a program using c++. Write a program that uses a loop to keep asking the user for a sentence, and for each sentence tells the user if it is a palindrome or not. The program should keep looping until the user types in END. After that, the program should display a count of how many sentences were typed in and how many palindromes were found. It should then quit. Your program must have (and use) at least four VALUE...
A gas station wants a program to keep track of sales. Your gas station sells diesel...
A gas station wants a program to keep track of sales. Your gas station sells diesel for 107.9 cents per litre and regular gas for 112.9 cents per litre. Have the user enter the type of fuel (1 = Regular gas, 2 = Diesel) and number of litres sold. Print out a total for each sale (remember fuel prices already include the GST). Once you enter a 0 for the type of fuel your program should stop and print out...
C++ Please. Break it down barney style if possible. Instructions Create a program to keep track...
C++ Please. Break it down barney style if possible. Instructions Create a program to keep track of the statistics for a kid’s soccer team. The program will have a structure that defines what data the program will collect for each of the players. The structure will keep the following data: Players Name (string) Players Jersey Number (integer) Points scored by Player (integer) The program will have an array of 12 players (use less for testing and development, use a constant...
USING PYTHON ONLY Write a gradebook program that lets a teacher keep track of test averages...
USING PYTHON ONLY Write a gradebook program that lets a teacher keep track of test averages for his or her students. Your program should begin by asking the teacher for a number of students in their class as well as the total # of tests that will be given to the class. Validate this information to ensure that the numbers entered are positive. Next, prompt the teacher to enter in scores for each student. Ensure that the values entered are...
Create JAVA PROGRAM, and write comment for codes also. 3) You want to keep track of...
Create JAVA PROGRAM, and write comment for codes also. 3) You want to keep track of your progress towards running a 10K. There are two kinds of races - 5K and 10K. The program needs to ask what race was run and what the time was in seconds until the user quits. When they quit, display the average and best time for each type of race in minutes.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT