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

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...
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...
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...
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...
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...
Write a C++ program for Euclids Algorithm that keeps track of the number of iterations (%...
Write a C++ program for Euclids Algorithm that keeps track of the number of iterations (% & loop) 1. Euclid’s Algorithm An alternative of the Euclidean algorithm for finding greatest common divisors (GCD) is repeatedly performing the modulo operation on two numbers until the remainder is 0. Here is the pseudocode for find the GCD of two positive numbers a and b using the Euclidean algorithm :while b ≠ 0 temp = b b = a mod t a =...
In this assignment, the program will keep track of the amount of rainfall for a 12-month...
In this assignment, the program will keep track of the amount of rainfall for a 12-month period. The data must be stored in an array of 12 doubles, each element of the array corresponds to one of the months. The program should make use of a second array of 12 strings, which will have the names of the months. These two arrays will be working in parallel. The array holding the month names will be initialized when the array is...
C++ Program -------------------- Project 5-1: Monthly Sales Create a program that reads the sales for 12...
C++ Program -------------------- Project 5-1: Monthly Sales Create a program that reads the sales for 12 months from a file and calculates the total yearly sales as well as the average monthly sales. Console Monthly Sales COMMAND MENU m - View monthly sales y - View yearly summary x - Exit program Command: m MONTHLY SALES Jan        14317.41 Feb         3903.32 Mar         1073.01 Apr         3463.28 May         2429.52 Jun         4324.70 Jul         9762.31 Aug        25578.39 Sep         2437.95 Oct         6735.63 Nov          288.11 Dec         2497.49...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT