l aboratory 8 Programming Methodologies Lab (14:332:254) March 26, 2018 Instruct
ID: 3738047 • Letter: L
Question
l aboratory 8 Programming Methodologies Lab (14:332:254) March 26, 2018 Instructions 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 $$000 in sales in a week receives $200 plus 9 percent ofs 5000,or a total of $650. Write a program (using an array of counters) that determines how many of the salespeople carned salaries in each of the following ranges (assume that cach salesperson's salary is truncated to an integer amount) a)s200-299 bjs300-399 c)5400-499 d) $500-599 e) 5600-699 0 $700-799 g) 5800-89 h) $900- 999 i) $1000 and over Few points . Please use a list of gross value and randomly populate it You should not use cin in your submission but for testing your code feel free to use it. For the number of salesperson, please use a const int and defined it within the code Submission Please only submit your h and epp files. NOTE - You need to Upload your files and then Submit them. The TAs will have no access to your files if you forget to submit them DOLLExplanation / Answer
#include <iostream>
#include <list>
using namespace std;
int main() {
list<int> gs = {246,789,145,462,563,489,977,321,125,145,654,785,566,465,647,1022,325,1546};
int a = 0;
int b = 0;
int c = 0;
int d = 0;
int e = 0;
int f = 0;
int g = 0;
int h = 0;
int i = 0;
for (auto it = gs.begin(); it != gs.end(); ++it) {
if (*it>=200 && *it<=299) {
a=a+1;
}
if (*it>=300 && *it<=399) {
b=b+1;
}
if (*it>=400 && *it<=499) {
c=c+1;
}
if (*it>=500 && *it<=599) {
d=d+1;
}
if (*it>=600 && *it<=699) {
e=e+1;
}
if (*it>=700 && *it<=799) {
f=f+1;
}
if (*it>=800 && *it<=899) {
g=g+1;
}
if (*it>=900 && *it<=999) {
h=h+1;
}
if (*it>=1000) {
i=i+1;
}
}
cout<<"a: "<<a<<endl;
cout<<"b: "<<b<<endl;
cout<<"c: "<<c<<endl;
cout<<"d: "<<d<<endl;
cout<<"e: "<<e<<endl;
cout<<"f: "<<f<<endl;
cout<<"g: "<<g<<endl;
cout<<"h: "<<h<<endl;
cout<<"i: "<<i<<endl;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.