java language please Use a onedimensional array to solve th
java language please - 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 $5,000 in sales in a week receives $200 plus 9% of $5,000, 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 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, $1,000 and over.
Summarize the results in tabular format.
Solution
package org.students;
public class SalaryBasedOnCommission {
public static void main(String[] args) {
//Declaring an array and initialize with values
int sales[] = { 1500, 2000, 4000, 7000, 5000, 6500, 9000, 11000, 12000,
7500, 8500, 9000, 10000, 12000, 13000, 8500, 7500, 6000, 5500 };
//Calling the method by passing the array as input
displayCounter(sales);
}
//This method will display the no of persons salary with in each range
private static void displayCounter(int sales[]) {
//Declaring variables
int counta = 0, countb = 0, countc = 0, countd = 0, counte = 0;
int countf = 0, countg = 0, counth = 0, counti = 0;
int basic_sal = 200;
int tot = 0;
//This for will count how many persons are there in particular range of salary
for (int i = 0; i < sales.length; i++) {
tot = (int) (basic_sal + 0.09 * sales[i]);
if (tot >= 200 && tot <= 299)
counta++;
else if (tot >= 300 && tot <= 399)
countb++;
else if (tot >= 400 && tot <= 499)
countc++;
else if (tot >= 500 && tot <= 599)
countd++;
else if (tot >= 600 && tot <= 699)
counte++;
else if (tot >= 700 && tot <= 799)
countf++;
else if (tot >= 800 && tot <= 899)
countg++;
else if (tot >= 900 && tot <= 999)
counth++;
else if (tot >= 1000)
counti++;
}
//Displaying the tabular form
System.out.println(\"** Displaying the How many salesPerson\'s salary in particular range **\");
System.out.println(\"Salary Range\\tNo Of Sales Persons\");
System.out.println(\"200-299 \\t \" + counta);
System.out.println(\"300-399 \\t \" + countb);
System.out.println(\"400-499 \\t \" + countc);
System.out.println(\"500-599 \\t \" + countd);
System.out.println(\"600-699 \\t \" + counte);
System.out.println(\"700-799 \\t \" + countf);
System.out.println(\"800-899 \\t \" + countg);
System.out.println(\"900-999 \\t \" + counth);
System.out.println(\">= 1000 \\t \" + counti);
}
}
_______________________
Output:
** Displaying the How many salesPerson\'s salary in particular range **
Salary Range No Of Sales Persons
200-299 0
300-399 2
400-499 0
500-599 1
600-699 2
700-799 2
800-899 3
900-999 2
>= 1000 7
________Thank You

