• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

my first Java nightmare

 
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm trying another route. Should this work?

 
Ranch Hand
Posts: 1296
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That looks fine to me. (By fine I mean it looks like it should work). Does it work like you expected it to?

IMO going through those "Java nightmares" just makes you stronger (to rewrite a tired cliche'). The next time, you will understand the pitfalls involved with this lesson. Especially with things like variable scope and shadowing primitive variables and such.

Garrett
[ February 10, 2006: Message edited by: Garrett Rowe ]
 
Jesse Crockett
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It still isnt working. I'm getting some weird ')' and '}' expected, for which I can't figure out where they should go. So I'm moving on to the next exercise, then maybe come back to this fresh (hopefully).
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This declaration:

static void printEmployeeInfo(StringBuffer employeeName, Double hourlyRate, Double hoursWorked, Double taxRate, Double pay[0], Double pay[1]) { ...

is causing the errors. The fact that you're passing array elements as arguments to this routine is irrelevant; when you declare the routine, you declare the arguments as plain old Doubles. The "Double pay[0]" syntax is what's wrong; you just want "Double pay0, Double pay1" or something like that (I don't know what those two elements represent or I'd give the parameters better names.)
 
author
Posts: 23959
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jesse Crockett:
It still isnt working. I'm getting some weird ')' and '}' expected, for which I can't figure out where they should go. So I'm moving on to the next exercise, then maybe come back to this fresh (hopefully).



First of all, don't worry about the tons of errors messages from the compiler. Deal with it one at at time. Fix one, then compile again. With experience later, you'll learn to do more than one.

Second, the most important items with the error message is the file and line number. Get a good editor, open the file specified, go to the line specified, and start from there. Errors having to do with braces are generally cause eariler -- so you may have to back up a bit. Having an editor that will help you match braces, would be a good idea too. Again, this will improve with experience.

Henry
 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hmmmm, shouldn't an array be initialized as:

int [] myArray = {1,2,4}//use{} instead of ()
 
reply
    Bookmark Topic Watch Topic
  • New Topic