Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Lab 3
- // James Strickland
- // 10/2/12
- // COP2224
- // LAB6 Salary [ARRAY]
- /* INSTRUCTIONS:
- (Salesperson Salary Ranges) Use a one-dimensional array to solve the following problem. 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
- */
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main()
- {
- // Initialize array
- int rangeSales[8] = {0}; // 0 to 9
- // Declare variables
- int salary = 200;
- int grossSales = 0;
- int commission = 0;
- int flooredNum = 0;
- cout << "Enter gross sales: ";
- cin >> grossSales;
- cout << endl;
- // floor(grossSales);
- while(grossSales != -1)
- {
- commission = grossSales * .09;
- salary = salary + commission;
- if (salary >= 200 && salary <= 300)
- {
- rangeSales[0]++;
- }
- else if (salary >= 300 && salary <= 399)
- {
- rangeSales[1]++;
- }
- else if (salary >= 400 && salary <= 500)
- {
- rangeSales[2]++;
- }
- else if (salary >= 500 && salary <= 600)
- {
- rangeSales[3]++;
- }
- else if (salary >= 600 && salary <= 700)
- {
- rangeSales[4]++;
- }
- else if (salary >= 700 && salary <= 800)
- {
- rangeSales[5]++;
- }
- else if (salary >= 800 && salary <= 900)
- {
- rangeSales[6]++;
- }
- else if (salary >= 900 && salary <= 1000)
- {
- rangeSales[7]++;
- }
- else if (salary >= 1000)
- {
- rangeSales[8]++;
- }
- } // end while
- cout << "$200-$299 range is: " << rangeSales[0] << endl;
- cout << "$300-$399 range is: " << rangeSales[1] << endl;
- cout << "$400-$499 range is: " << rangeSales[2] << endl;
- cout << "$500-$599 range is: " << rangeSales[3] << endl;
- cout << "$600-$699 range is: " << rangeSales[4] << endl;
- cout << "$700-$799 range is: " << rangeSales[5] << endl;
- cout << "$800-$899 range is: " << rangeSales[6] << endl;
- cout << "$900-$999 range is: " << rangeSales[7] << endl;
- cout << "$1000 and up : " << rangeSales[8] << endl;
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement