Write a program that displays the frequencies of sales commissions. The commission for each salesperson is calculated as \$200 plus 9% of gross sales. For example a salesperson who grosses \$5000 in a week makes 200 + .09 *5000 = 200 + 450 = \$650 The program will input a series of weekly gross sales for each salesperson. The program will output the number of salespeople in each of the following ranges:

\$200 – 299
\$300 – 399
\$400 – 499
\$500 – 599
\$600 – 699
\$700 – 799
\$800 – 899
\$900 – 999
\$1000 and over

So far i have written some codes but I am still so stuck. I found a psedocode somewhere online but I do not understand how to write some of the codes.
I know this is a simple code for others but Im still new at this.

``````import java.util.Scanner;
public class Sales
{
long freqCount[] = new long[9]; // array for storing frequencies
int grossSales = getSalary();
Scanner stdin = new Scanner(System.in)
int salesPeople = 0;
System.out.print("How many salespeople are there? ");
salesPeople = stdin.nextInt();
-- //Call getGrossSales  how do I call the getGrossSales method?
long grossSales[] = new long[salesPeople];
long salesComm[] = new long[salesPeople];
getSalesInput(grossSales);
salesCommissionCalc(grossSales, salesComm);
frequencyCount(salesComm, freqCount);
frequencyDisplay(freqCount);

}
}

public class
{
public static void main(String[] args){
//Declare and initialize variables
//Prompt for number of salespeople (needed to dimension sales arrays).
//Call getGrossSales
//Declare arrays for gross sales and sales commission
//If number of salespeople greater than zero, begin instruction.
//Call method to get gross sales per salesperson, use to populate array.
//Takes gross sales array by reference.
//Call method to calculate sales commissions. Takes gross sales array as parameter

//Needs variables for: frequency(array), initialize all values at 0.

//Call frequency array storage method, which should iterate through array to display results
}
} //end main method
``````

You can't just throw code into a class definition like that - executable statements need to be inside a method.
The comments in the main methods are a good start. The idea is that you should take each line of those comments one at a time and write the code according to the comment - put the code immediately after the comment

I just dont understand some of the psedocodes until I get a compared code.

Here is what I have so far, still a lot of errors

``````import java.util.Scanner;

public class Hwk11
{
public static void main (String args[])
{
//declare and intialize vars
// array for storing frequencies
long freqCount[] = new long[9];

Scanner stdin = new Scanner(System.in);
int salesPeople = 0;

//Prompt number of salespeople
System.out.print("How many salespeople are there? ");
salesPeople = stdin.nextInt();

// Call getGrossSales
getGrossSales();

// Declare arrays for gross sales and sales commission
long grossSales[] = new long[salesPeople];
long salesComm[] = new long[salesPeople];

// If number of salespeople are greter than zero, begin instructions.
getSalesInput(grossSales);
// Takes gross sales array by reference

// Call method to calculate sales commission
salesCommissionCalc(grossSales, salesComm);

// Vars for frequency(array), initialize all values to 0.

// Call frequency array storage method.
frequencyCount(salesComm, freqCount);
frequencyDisplay(freqCount);

}
public double getGrossSales(int grossSales)
{
int counterArray[] = new int[grossSales];

// Counter initialize
for (int i = 0; i < counterArray.length; i++)
{
// Prompt first gross sales values in array
Scanner input = new Scanner(System.in);
System.out.println("Enter sales amount -1 to end: ");
counterArray[index] = input.nextInt();
}

// While counter is less than number of salespeople
while (grossSales <= 0)
{
// Increase counter
// How do I write the increase counter?
grossSales++;
System.out.println("Enter sales amount -1 to end");
counterArray[index] = input.nextInt();
}
// Return gross sales array
return grossSales;
}

public int getSalesComm(int grossSales[])
{
// Declare sales commission array

// Iterate through gross sales array
// Calcualte gross sales commission
double salary = (200 + (0.09 * grossSales));
// Store caluclation in commission array
-- How do I store commission array?
}
public static void freqStore(int salesComm)
{
//Method both loads frequencies based on commission, and displays results to
screen.
//Has arrays for frequency (static), frequencySums,
//and frequency_with_Salesperson_ID array (array for storing which salespeople were in
which frequency range)
//Initialize result message and result array
//Append result message opening lines (i.e. The result is
)
//Loop through sales
//Loop through frequency
//if sales > frequency[i] then
//Increment frequency counter
//else
//Increment frequency sums based on freqCounter(i - 1)
//Store salespersonID in matching frequency_with_Salesperson_ID ID
//endif

//EndFreqLoop
//Increment sales counter
//EndSalesLoop

}

}
``````

I cleaned it up and starting to see the picture better here is what I have so far

``````import java.util.Scanner;
public class Sales
{
public static void main (String args[])
{
int countSalesPeople = 0;

// Prompt for number of salespeople (needed for array)
Scanner stdin = new Scanner(System.in);
int []sales = new int[countSalesPeople];
System.out.println("Please enter # of salespeople: ");
countSalesPeople = stdin.nextInt();

//If number of salespeople greater than zero begin.

//Call getGrossSales
double[] grossSales = null;
grossSales = getGrossSales(countSalesPeople);

// calculate commission for each sales guy
double[] commissions = null;
commissions = calcCommissions(grossSales);

double[] freqCounts = null;

}
public static double[] getGrossSales(int countSalesPeople)
{
int index = 0;
int array[] = new int[9];
double grossSales[] = new double[countSalesPeople];

for (index =0; index < countSalesPeople; index++)
{
Scanner input = new Scanner(System.in);
System.out.println("Enter sales amount of emp " +
(index + 1));
grossSales[index] = input.nextDouble();
}

for (index = 0; index < countSalesPeople; index++)
{
System.out.println("Emp # " + (index + 1) +
" Has Sales of " + grossSales[index]);
}
return grossSales; // need to return an array of doubles
}
public static double[] calcCommissions(double[] grossSales)
{
double commissions[] = new double[grossSales.length];

commissions = 200 + 0.09 * grossSales[index];
return commissions;
}
}
``````

Now it is saying the 0.09 * grossSales[index] is incompatible.
I know this is just a type error, what do I write there?

In your last method calcComissions, you are using an array and you re not specifying on wich index of the array comissions the calculation that you re doing should go to, also you should check your index variable, you will get an error since it s not a public variable.

After a quick look I can't see an "index" variable defined that's in scope at line 52 (the one on line 29 is local to the getGrossSales method only).
(And you seem to be missing a loop in calcComissions anyway)

``````public static double[] calcCommissions(double[] grossSales)
{
double commissions[] = new double[grossSales.length];
for (int i=0;i<commissions.length;i++)
{
commissions[i] = 200 + 0.09 * grossSales[i];
}
return commissions;
}
``````

try to substitute your last method with this.