82.4k views
2 votes
Use a one-dimensional array to solve the following problem: 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 $5000 in sales in a week receives $200 plus 9 percent of $5000, or a total of $650. Write a program (using an array of counters), for a company with 20 employees, 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): a) $200-299 b) $300-399 c) $400-499 d) $500-599 e) $600-699 f) $700-799 g) $800-899 h) $900-999 i) $1000 and over.

User Matt Cofer
by
4.8k points

1 Answer

0 votes

Answer:

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\t\tCOUNT");

for(i=0;i<8;i++)

System.out.println("$"+(i*100+200)+"-"+(i*100+299)+"\t"+totals[i]);

System.out.println("$1000 and over\t"+totals[i]);

}

}

Step-by-step explanation:

User Cory Madden
by
5.7k points