• Post Reply Bookmark Topic Watch Topic
  • New Topic

Question on Exceptions Handling  RSS feed

 
Dan Good
Ranch Hand
Posts: 49
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys, haven't posted in a while, but my programming instructor asked us to take a class and implement a "try, catch" block to catch an exception. Here's the question:

Modify the findBestPaid method in the Company class to catch an InputMismatchException (or NoSuchElementException, if the line in the file has a name and an int for hours worked, but no pay rate).

I added a try/catch block, but I'm getting some issues, and I can tell my block is not written correctly.



Let me know if you can help me 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
Exactly what are your issues? Doesn't look like it would even compile.
 
Campbell Ritchie
Marshal
Posts: 56600
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually you can always avoid the InputMismatchException from keyboard input. So there is no need to catch it.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!