Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(Salary Classification) A company pays its salespeople on a commission basis. Th

ID: 3802873 • Letter: #

Question

(Salary Classification) A company pays its salespeople on a commission basis. The salespeople each receive $200 per week plus 9 percent of their gross sales for that week. For example, a salesperson who grosses $5000 in sales in a week receives $200 plus 9 percent of$5000,or a total of $650. Write a program (using an array of counters) that determines how many of the salespeople earned salaries in each of the following ranges (assume that each salesperson’s salary is truncated to an integer amount): a)$200–299 b)$300–399 c)$400–499 d) $500–599 e) $600–699 f) $700–799 g) $800–899 h) $900–999 i) $1000 and over. Instead of static array, please use pointers!!!! Your program should run in C++ without error and correctly categorize each salary range!

Explanation / Answer

// C++ code

#include <iostream>
#include <fstream>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <time.h>
using namespace std;

#define pluspercent 0.09

int main()
{
   int *range = new int[9];
  
   for (int i = 0; i < 9; ++i)
   {
       *(range + i) = 0;
   }

   int sales;
   double totalSales;
   while(true)
   {
       cout << "Enter an employee's weekly sales (end -1 to end): ";
       cin >> sales;

       if(sales < 0)
           break;

       totalSales = sales + sales*pluspercent;
       cout << totalSales << endl;

       if(totalSales <= 299)
           (*(range+0))++;
       else if(totalSales <= 399)
           (*(range+1))++;
       else if(totalSales <= 499)
           (*(range+2))++;
       else if(totalSales <= 599)
           (*(range+3))++;
       else if(totalSales <= 699)
           (*(range+4))++;
       else if(totalSales <= 799)
           (*(range+5))++;
       else if(totalSales <= 899)
           (*(range+6))++;
       else if(totalSales <= 999)
           (*(range+7))++;
       else
           (*(range+8))++;
   }

   cout << " Employees in salary range: ";
   cout << "$200-$299: " << (*(range+0)) << endl;
   cout << "$300-$399: " << (*(range+1)) << endl;
   cout << "$400-$499: " << (*(range+2)) << endl;
   cout << "$500-$599: " << (*(range+3)) << endl;
   cout << "$600-$699: " << (*(range+4)) << endl;
   cout << "$700-$799: " << (*(range+5)) << endl;
   cout << "$800-$899: " << (*(range+6)) << endl;
   cout << "$900-$999: " << (*(range+7)) << endl;
   cout << "$1000 and over: " << (*(range+8)) << endl;

   return 0;
}

/*
output:

Enter an employee's weekly sales (end -1 to end): 1242
Enter an employee's weekly sales (end -1 to end): 5123
Enter an employee's weekly sales (end -1 to end): 824
Enter an employee's weekly sales (end -1 to end): 1031
Enter an employee's weekly sales (end -1 to end): 919
Enter an employee's weekly sales (end -1 to end): 400
Enter an employee's weekly sales (end -1 to end): -1

Employees in salary range:
$200-$299: 0
$300-$399: 0
$400-$499: 1
$500-$599: 0
$600-$699: 0
$700-$799: 0
$800-$899: 1
$900-$999: 0
$1000 and over: 4


*/