I have been working on this array problem since last Friday. We are to accept an employee's gross sales, multiply that by 9%(to find commission) add $200 for weekly salary. Then the program takes that dollar amount and tallies payroll with ( *'s) beside salary groupings....
$200-299 ****
$300-399 **
$400-499* ......ect

my problem is I can't get this to complie to even see how close I am. My compiler keeps giving this error...

\Sales.java:30: ')' expected
salary = (double 200 + (grossSales * .09 ));
java:30: ';' expected

java:30: ';' expected
salary = (double 200 + (grossSales * .09 ));
I'm lost and frustrated and need some advice......Here is what I have

/import java.util.Scanner;

public class Sales

	//counts number or salespersons in different salary ranges

	public void countRanges()
Scanner input = new Scanner( System.in );

double salary;//salespersons pay
double grossSales;//sales to base commission of 9% on

		//ininialize the values in the array to zero

salary = 0;
grossSales = 0;

		//read in values and assign them to the appropriate ranges

		System.out.print( "Enter Gross Sales or enter a negative number to exit" );
		dollars = input.next.Int();
		grossSales = dollars;

		while ( dollars >= 0 )

			//calculate salary an get range by salary/100
			salary =  (double 200 + (grossSales * .09 ));
			range = ( salary/100 );

			if ( range > 10 )

			range = 10;

			//count totals for every range
			for ( int counter = 0; counter < array.length; counter++ )
		total += array[ counter ];

		if ( counter == 10 )
		System.out.printf( "%5d: ", 1000 );
		System.out.printf( "%3d-%3d: ", counter * 100, counter * 100 + 9 );

			//enter next sales amount (negative to end)

			System.out.print( "Enter next Gross Sales or enter a negative number to exit" );
			grossSales = input.nextInt();

		}//end while

	//print chart
for ( int stars = 0; starts < array [counter]; star++ )
System.out.print( "*" );

}//end method countRanges

}//end class Sales
8 Years
Discussion Span
Last Post by stultuske

First, use [code] [/code] tags around your code so it remains readable.
Second, get the "double" out of that expression you posted the error on (line 30). It doesn't belong in there.
Lastly, I don't think input.next.Int() is a valid method on the the Scanner class. Check the API.


I put the "(" at the beginning of my code and the ")" at the end--is that not what is meant by (code).

Edited by mike_2000_17: Fixed formatting


No, "code" is the tag name.

[code] your code goes here [/code]

You can also highlight the code and click the little "#" button on the toolbar to surround it with code tags.


thank you for the information--although I can't edit my text now because of a 30 min rule (should I repost)


You were correct on both issues you pointed out. I have corrected them but now have 16 errors. I will be a while trying to get them down to a couple so that I can re-post if necessary. Thanks

This question has already been answered. Start a new discussion instead.
Please be thoughtful and detailed and be sure to adhere to our posting rules.