A company pays its salespeople on a commission basis. The salespeople each recei
ID: 3810762 • Letter: A
Question
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): $200-299 $300-399 $400-499 $500-599 $600-699 $700-799 $800-899 $900-999 $1000 and over.Explanation / Answer
#include<iostream>
#include<cmath>
#include<string>
using namespace std;
//declare variable to hold 9% of their gross
const double percent = 0.09;
const int weekly_pay = 200;
int main()
{
double gross_earned,total_earning;
int c,count = 0;
//declare array of integer for counting number of salesperson in particular range ,size of arraya as 8 because there are 9 ranges
int range[9] = { 0 };
//declare array of string for displaying appropriate message for each range
string range_msg[10] = { "200-299", "300-399", "400-499", "500-599", "600-699", "700-799", "800-899", "900-999", "1000 and over" };
do
{
cout << "Enter the salesperson gross sale: ";
cin >> gross_earned;
//calculate total_earning = gross_earned + gross_earned*percent ;
total_earning = weekly_pay + gross_earned*percent;
if ((int)total_earning >= 200 && (int)total_earning <= 299)
{
++range[0];
}
if ((int)total_earning >= 300 && (int)total_earning <= 399)
{
++range[1];
}
if ((int)total_earning >= 400 && (int)total_earning <= 499)
{
++range[2];
}
if ((int)total_earning >= 500 && (int)total_earning <= 599)
{
++range[3];
}
if ((int)total_earning >= 600 && (int)total_earning <= 699)
{
++range[4];
}
if ((int)total_earning >= 700 && (int)total_earning <= 799)
{
++range[5];
}
if ((int)total_earning >= 800 && (int)total_earning <= 899)
{
++range[6];
}
if ((int)total_earning >= 900 && (int)total_earning <= 999)
{
++range[7];
}
if ((int)total_earning >= 1000 )
{
++range[8];
}
count++;
cout << "Want to continue entering gross of salespesron:(y/n?): ";
fflush(stdin);
c = getchar();
} while (c !='n');
for (int i = 0; i < 9; i++)
{
cout << range_msg[i] << ": " << range[i] << endl;
}
}
-----------------------------------------------------------------------------------------------------------
//output
Enter the salesperson gross sale: 5000
Want to continue entering gross of salespesron:(y/n?): y
Enter the salesperson gross sale: 3000
Want to continue entering gross of salespesron:(y/n?): y
Enter the salesperson gross sale: 3500
Want to continue entering gross of salespesron:(y/n?): y
Enter the salesperson gross sale: 6000
Want to continue entering gross of salespesron:(y/n?): y
Enter the salesperson gross sale: 6500
Want to continue entering gross of salespesron:(y/n?): y
Enter the salesperson gross sale: 7000
Want to continue entering gross of salespesron:(y/n?): y
Enter the salesperson gross sale: 7500
Want to continue entering gross of salespesron:(y/n?): y
Enter the salesperson gross sale: 8000
Want to continue entering gross of salespesron:(y/n?): y
Enter the salesperson gross sale: 8500
Want to continue entering gross of salespesron:(y/n?): y
Enter the salesperson gross sale: 3500
Want to continue entering gross of salespesron:(y/n?): y
Enter the salesperson gross sale: 2300
Want to continue entering gross of salespesron:(y/n?): y
Enter the salesperson gross sale: 1200
Want to continue entering gross of salespesron:(y/n?): y
Enter the salesperson gross sale: 1000
Want to continue entering gross of salespesron:(y/n?): y
Enter the salesperson gross sale: 9000
Want to continue entering gross of salespesron:(y/n?): y
Enter the salesperson gross sale: 9500
Want to continue entering gross of salespesron:(y/n?): y
Enter the salesperson gross sale: 3678
Want to continue entering gross of salespesron:(y/n?): y
Enter the salesperson gross sale: 9878
Want to continue entering gross of salespesron:(y/n?): y
Enter the salesperson gross sale: 1400
Want to continue entering gross of salespesron:(y/n?): y
Enter the salesperson gross sale: 1600
Want to continue entering gross of salespesron:(y/n?): n
200-299: 1
300-399: 3
400-499: 2
500-599: 3
600-699: 1
700-799: 2
800-899: 2
900-999: 2
1000 and over: 3
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.