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

How to solve this question using the for loop and if statement (array) in C++. E

ID: 3740602 • Letter: H

Question

How to solve this question using the for loop and if statement (array) in C++.

Exercise #1: Salaries A company pays its salesmen on a commission basis. Each salesman receives $100 per week plus 7 percent of their gross sales for that week. For example, a salesman who grosses $5000 in sales in a week receives $100 plus 7 percent of S5000 (or a total of $450). Write a program in C++ that uses a one dimensional array to determine how many of the salesmen earned salaries fall in each of the following ranges a) $100-$199 b) $200-$299 c) $300-$399 d) S400-$499 e) $500-$599 f) $600-S699 g) S700-$799 h) $800-$899 i) $900-S999 j) $1000 and over

Explanation / Answer

#include <iostream>

using namespace std;

int main() {

int ar[10]={0};

int over=0; //variable fot over $1000

int sales;

cout<<"Enter employee gross sales(-1 to end)::";

cin>>sales;

while(sales!=-1)

{

double sum=(0.07*sales)+100; //7% of sales + $ 100

cout<<"Employee commision is $"<<sum <<endl;

int temp=sum/100;

if(temp<10)

ar[temp-1]++;

else

over++;

cout<<"Enter employee gross sales(-1 to end)::";

cin>>sales;

}

cout<<" Employees in the rage::"<<endl;

//printing output

for(int i=0;i<9;i++)

{

int te1=(i+1)*100;

int te2=te1+99;

cout<<"$"<<te1<<"-$"<<te2<<" :"<<ar[i]<<endl;

}

cout<<"over $1000: "<<over<<endl;

return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote