. (Sales Commissions) Use a one-dimensional array to solve the following problem
ID: 3622886 • Letter: #
Question
. (Sales Commissions) Use a one-dimensional 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 $5000 in sales in a week receives $200 plus 9% of $5000, or a total of $650. Write an application (using an array of counters) that determines how many of the salespeople earned salaries in each of the following ranges (assume that each salespersonExplanation / Answer
please rate - thanks
import java.util.Scanner;
public class commission
{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int totals[]={0,0,0,0,0,0,0,0,0};
int n,sales,i,index;
double salary;
System.out.print("how many salesmen do you have? ");
n=input.nextInt();
for(i=1;i<=n;i++)
{System.out.print("Salesman "+i+" enter sales: ");
sales=input.nextInt();
salary=200+(int)(.09*sales);
System.out.printf("Salary=$%.2f ",salary);
index=(int)salary/100-2;
if(index>8)
index=8;
totals[index]++;
}
System.out.println("SUMMARY SALES COUNT");
for(i=0;i<8;i++)
System.out.println("$"+(i*100+200)+"-"+(i*100+299)+" "+totals[i]);
System.out.println("$1000 and over "+totals[i]);
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.