simple array problem not so simple

Thread Solved

Join Date: Jan 2009
Posts: 17
Reputation: tmoney7566 is an unknown quantity at this point 
Solved Threads: 0
tmoney7566 tmoney7566 is offline Offline
Newbie Poster

simple array problem not so simple

 
0
  #1
Feb 3rd, 2009
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....
ex
$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


  1. /import java.util.Scanner;
  2.  
  3. public class Sales
  4. {
  5.  
  6. //counts number or salespersons in different salary ranges
  7.  
  8. public void countRanges()
  9. {
  10. Scanner input = new Scanner( System.in );
  11.  
  12. double salary;//salespersons pay
  13. double grossSales;//sales to base commission of 9% on
  14.  
  15. //ininialize the values in the array to zero
  16.  
  17. salary = 0;
  18. grossSales = 0;
  19.  
  20. //read in values and assign them to the appropriate ranges
  21.  
  22. System.out.print( "Enter Gross Sales or enter a negative number to exit" );
  23. dollars = input.next.Int();
  24. grossSales = dollars;
  25.  
  26. while ( dollars >= 0 )
  27. {
  28.  
  29. //calculate salary an get range by salary/100
  30. salary = (double 200 + (grossSales * .09 ));
  31. range = ( salary/100 );
  32.  
  33. if ( range > 10 )
  34.  
  35. range = 10;
  36.  
  37. //count totals for every range
  38. for ( int counter = 0; counter < array.length; counter++ )
  39. total += array[ counter ];
  40.  
  41. if ( counter == 10 )
  42. System.out.printf( "%5d: ", 1000 );
  43. else
  44. System.out.printf( "%3d-%3d: ", counter * 100, counter * 100 + 9 );
  45.  
  46.  
  47. //enter next sales amount (negative to end)
  48.  
  49. System.out.print( "Enter next Gross Sales or enter a negative number to exit" );
  50. grossSales = input.nextInt();
  51.  
  52. }//end while
  53.  
  54. //print chart
  55. for ( int stars = 0; starts < array [counter]; star++ )
  56. System.out.print( "*" );
  57.  
  58. }//end method countRanges
  59.  
  60. }//end class Sales
Last edited by tmoney7566; Feb 3rd, 2009 at 7:22 pm.
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 4,438
Reputation: Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of 
Solved Threads: 510
Moderator
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Industrious Poster

Re: simple array problem not so simple

 
0
  #2
Feb 3rd, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 17
Reputation: tmoney7566 is an unknown quantity at this point 
Solved Threads: 0
tmoney7566 tmoney7566 is offline Offline
Newbie Poster

Re: simple array problem not so simple

 
0
  #3
Feb 3rd, 2009
I put the "[" at the beginning of my code and the "]" at the end--is that not what is meant by [code].
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 4,438
Reputation: Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of 
Solved Threads: 510
Moderator
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Industrious Poster

Re: simple array problem not so simple

 
0
  #4
Feb 3rd, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 17
Reputation: tmoney7566 is an unknown quantity at this point 
Solved Threads: 0
tmoney7566 tmoney7566 is offline Offline
Newbie Poster

Re: simple array problem not so simple

 
0
  #5
Feb 3rd, 2009
thank you for the information--although I can't edit my text now because of a 30 min rule (should I repost)
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 4,438
Reputation: Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of 
Solved Threads: 510
Moderator
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Industrious Poster

Re: simple array problem not so simple

 
0
  #6
Feb 3rd, 2009
Well, it depends on where your code stands now after addressing the other two things I mentioned.
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 17
Reputation: tmoney7566 is an unknown quantity at this point 
Solved Threads: 0
tmoney7566 tmoney7566 is offline Offline
Newbie Poster

Re: simple array problem not so simple

 
0
  #7
Feb 3rd, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 706
Reputation: stultuske is a jewel in the rough stultuske is a jewel in the rough stultuske is a jewel in the rough 
Solved Threads: 84
stultuske's Avatar
stultuske stultuske is offline Offline
Master Poster

Re: simple array problem not so simple

 
0
  #8
Feb 4th, 2009
you can also post the new errors here.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC