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

Use a single-subscripted array to solve the following problem. A company pays it

ID: 3734573 • Letter: U

Question

Use a single-subscripted array to solve the following problem. A company pays its salespeople on a commission basis. The salespeople receive $200 per week plus 9% of their gross sales for that week. For example, a salesperson who grosses $3,000 in sales in a week receives $200 plus 9% of $3,000, or a total of $470. Prompt the user for employees' weekly gross sales until control-d is pressed, then determine 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).

1. $200-$299
2. $300-$399
3. $400-$499
4. $500-$599
5. $600-$699
6. $700-$799
7. $800-$899
8. $900-$999
9. $1000 and over

please no java thank you

Explanation / Answer

// SalesPeople.cpp : Defines the entry point for the console application.

//

#include "stdafx.h"

#include <array>

#include <string>

#include <iostream>

#include <sstream>

int get_index(int gross)

{

if (gross >= 200 && gross <= 299)

return 0;

if (gross >= 300 && gross <= 399)

return 1;

if (gross >= 400 && gross <= 499)

return 2;

if (gross >= 500 && gross <= 599)

return 3;

if (gross >= 600 && gross <= 699)

return 4;

if (gross >= 700 && gross <= 799)

return 5;

if (gross >= 800 && gross <= 899)

return 6;

if (gross >= 900 && gross <= 999)

return 7;

if (gross >= 1000)

return 8;

}

int _tmain(int argc, _TCHAR* argv[])

{

std::array<int, 9> counts={ 0 };

int gross_sales=0;

std::string line;

int commission, salary;

while (std::getline(std::cin, line))

{

std::stringstream ss(line);

ss >> gross_sales;

commission = gross_sales*0.09;

salary = 200 + commission;

counts[get_index(salary)]++;

}

int lb = 200;

int range = 99;

size_t i = 0;

for (; i < counts.size()-1; ++i)

{

std::cout << i + 1 << ". $" << lb << "-" << lb + range << " - " << counts[i] << std::endl;

lb += 100;

}

std::cout << i + 1 << ". $" << lb << " and over" << " - " << counts[i] << std::endl;

system("pause");

return 0;

}