• Post Reply Bookmark Topic Watch Topic
  • New Topic

array error  RSS feed

 
Ryan Gordon
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Im trying to make a program to calculate 2 different employees bonus, based on quarterly and annual contributions. i have this code so far



which compiles fine


and



im getting these errors






after I fix this issue I plan on using some type of if staement or for loop or both to do the necessary calculations, just very confused as to this error. thank you very much.
 
Ryan Gordon
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
forgot to mention in first program I commentded out the constructor because it doesnt work and I am unsure why.
 
Junilu Lacar
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're missing an identifier (a name) for the double[] that you're trying to declare.
 
Junilu Lacar
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, but ItDoesntWorkIsUseless - Please TellTheDetails  (click on those, they are links)
 
Ryan Gordon
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I will be more precise from now on sorry, I tried doing what you said and it removed 2 errors, now I tried two different things and I tried to add .class and .bonusCalculator and i get 2 errors.











Please help, thank you.
 
Junilu Lacar
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What exactly are you trying to achieve with those statements. Obviously, that's not valid Java syntax. Are you trying to multiply each of the elements of an array by a number? If that's what you're trying to do, then you have to use a loop and multiply each element in the array by the number. An array is basically an object, not a number, so trying to multiply an object by a number doesn't make sense in Java.  You can only multiply a number by another number.
 
Ryan Gordon
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator






I am trying to calculate if an employee will get a bonus based on monthly and annual contributions and yes I am trying to multiply the array but now I know I cant do that. I tried to continue with your advice but I am still having trouble, can you give me an example? I cant figure this out...
 
Carey Brown
Saloon Keeper
Posts: 3329
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at the type you are declaring ALL occurrences of "quarterly" and look at how they are being used.

Note that local variables in main are not visible in your other method unless you pass them in when the method is called.

Also, I think you are writing too many lines of code before you see if they compile. Start over, write 4 or 5 lines, see if it compiles, repeat.
 
Junilu Lacar
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sometimes when a compiler error points to the beginning of a line of code, the actual syntax error could be on the preceding line of code. You're missing a semicolon on the line above where the first error is being reported.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!