Hi, I am having trouble having the answer increment, I know it seems the increment value is lost in the method but I cannot find a way to make that work, can you please give some suggestions. Thanks. This program is supposed to ask the user to enter sales amount and increment the value corresponding to the weekly salary.
public class SalesCommissions {
//metthos to get input from the user
private int array[];
public void SalesCalc()
{
Scanner input = new Scanner(System.in);
//create an array to hold the values of the salaries earned per week
int array[] = new int [ 9 ];
//set the array values to 0
for ( int counter = 0; counter < array.length; counter++ )
array[ counter ] = 0;
//ask the user to enter the grross sales amount per week
System.out.print("Please enter the sales amount(-1 to exit)");
double saleAmount = input.nextDouble();
//calculate the commission and weekly salary
while(saleAmount >= 0) {
// calculate commission
double commission = 0.09*saleAmount;
// calculate weekly salary based on commission
double salary = commission+200;
System.out.println( "Enter sales amount (-1 to exit): " );
saleAmount = input.nextDouble();
}}// end while
// displayResults();
private void displayResults(double salary, int array[]){
array = new int[9];
int[] frequency= new int[9];
if (salary>= 1000.00) {
++frequency[array[0]++];
} else if (salary>= 900.00) {
++frequency[array[0]++];
} else if (salary >= 800.00) {
++frequency[array[0]++];
} else if (salary >= 700.00) {
++frequency[array[0]++];
} else if (salary >= 600.00) {
++frequency[array[0]++];
} else if (salary >= 500.00){
++frequency[array[0]++];
} else if (salary >= 400.00) {
++frequency[array[0]++];
} else if (salary >= 300.00) {
++frequency[array[0]++];
} else if (salary >= 200.00) {
++frequency[array[0]++];
}
//end method increment
for ( int i= 0; i < array.length; i++ )
array[ i ] = 0;
for ( int i= 0; i< array.length; i++ )
++frequency[array[i]];
System.out.println("Values\t\tSalary");
for ( int j= 0; j< frequency.length; j++ )
System.out.printf( "$%d-$%d \t%d\n",(200 + 100 * j), (299 + 100 * j), frequency[j]);
// displayResults(saleAmount, array);
}//end method Sales Calc
//method to increment array
//method to display the results
}