write code one-dimensional amay to solve the following problem Acompany pays ics
ID: 3577622 • Letter: W
Question
write code
one-dimensional amay to solve the following problem Acompany pays ics salespeople on a a commission basis. The salespeople per week plus their gross sales for that week. For ofse50 a salesperson who grosses S5000 in sales in a week receives $200 plus 9% of $5000, or a total Complete the following Java program adding HERE by code where indicated by ADD CODE (using an array of counters) that determines how the salespeople earned salaries in each of many of the salary ranges shown below summarize the results in tabular format: sales commissions int, double int Program gets the weekly sales amount of each salesperson, calculate the salesperson's weekly salary based on the formula: $200.00 of their weekly sales amount Pro then tabulates the salesperson based on their salary $300.00 8299.99 c) $400.00 $399.99 d) 3500.00 $499.99 $599.99 e) $700.00 $699.99 $799.99 $800.00 h) $900.00 S899,99 $999.99 finally, program and ver public outputs the numbers of salespeople per salary range class sions public static void main (stri args) ang final final int NUM final double SENTINEL SALES 0.0. double double salary RATE 0.09 Scanner kbd 1.0; new Scanner (System- in i 1. of counters create the integer array ADD CODE Question 4 continues on page 5 Page 4 of 6Explanation / Answer
package org.students;
import java.util.Scanner;
public class SalesCommissions {
public static void main(String[] args) {
//Declaring variables
final int NUM_RANGES = 9;
final double SENTINEL_SALES = 0.0;
final double COMMISSIN_RATE = 0.09;
double salary = 1.0;
//Scanner class object is used to read the inputs entered by the user
Scanner kbd = new Scanner(System.in);
//Creating an integer array based on the size of the ranges
int ranges[] = new int[NUM_RANGES];
//Declaring variables
double current_Sales=0.0;
int count=0;
//This loop continues to execute until the user entered a positive value
while (true) {
//Getting the sales entered by the user
System.out.print("Enter Sales of the person "+(++count)+":$");
current_Sales = kbd.nextDouble();
//If the user entered a negative value the display error message
if (current_Sales < 0) {
System.out.println("** Invalid.Sales Must be Positive **");
continue;
}
else
break;
}
//This loop continues to execute until the user enters 0.0 value
while (current_Sales != SENTINEL_SALES) {
//Calculating the salary of an employee
salary = 200 + current_Sales * 0.09;
//Based on the salary the corresponding value will be incremented by 1
if (salary >= 200 && salary <= 299.99)
ranges[0]++;
else if (salary >= 300 && salary <= 399.99)
ranges[1]++;
else if (salary >= 400 && salary <= 499.99)
ranges[2]++;
else if (salary >= 500 && salary <= 599.99)
ranges[3]++;
else if (salary >= 600 && salary <= 699.99)
ranges[4]++;
else if (salary >= 700 && salary <= 799.99)
ranges[5]++;
else if (salary >= 800 && salary <= 899.99)
ranges[6]++;
else if (salary >= 900 && salary <= 999.99)
ranges[7]++;
else if (salary >= 1000)
ranges[8]++;
//This loop continues to execute until the user entered a positive value
while (true) {
//Getting the sales entered by the user
System.out.print("Enter Sales of the person "+(++count)+":$");
current_Sales = kbd.nextDouble();
//If the user entered a negative value the display error message
if (current_Sales < 0) {
System.out.println("** Invalid.Sales Must be Positive **");
continue;
} else
break;
}
}
//Displaying the salary range and no of sales person in that salary range
System.out.println(" Salary Range No Of People");
System.out.println("$200.00 - $299.99 "+ranges[0]);
System.out.println("$300.00 - $399.99 "+ranges[1]);
System.out.println("$400.00 - $499.99 "+ranges[2]);
System.out.println("$500.00 - $599.99 "+ranges[3]);
System.out.println("$600.00 - $699.99 "+ranges[4]);
System.out.println("$700.00 - $799.99 "+ranges[5]);
System.out.println("$800.00 - $899.99 "+ranges[6]);
System.out.println("$900.00 - $999.99 "+ranges[7]);
System.out.println(">=$1000.00 "+ranges[8]);
}
}
________________________
Output:
Enter Sales of the person 1:$5500
Enter Sales of the person 2:$5000
Enter Sales of the person 3:$4500
Enter Sales of the person 4:$5500
Enter Sales of the person 5:$6000
Enter Sales of the person 6:$6500
Enter Sales of the person 7:$7000
Enter Sales of the person 8:$5500
Enter Sales of the person 9:$4500
Enter Sales of the person 10:$7000
Enter Sales of the person 11:$7500
Enter Sales of the person 12:$8000
Enter Sales of the person 13:$8500
Enter Sales of the person 14:$5500
Enter Sales of the person 15:$4500
Enter Sales of the person 16:$0.0
Salary Range No Of People
$200.00 - $299.99 0
$300.00 - $399.99 0
$400.00 - $499.99 0
$500.00 - $599.99 0
$600.00 - $699.99 8
$700.00 - $799.99 2
$800.00 - $899.99 3
$900.00 - $999.99 2
>=$1000.00 0
___________Thank You
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.