• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Junilu Lacar
  • Martin Vashko
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Scott Selikoff
  • salvin francis
  • Piet Souris

Question on Exceptions Handling

 
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!
 
Saloon Keeper
Posts: 6449
61
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
 
Marshal
Posts: 66498
251
  • 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.
 
He's giving us the slip! Quick! Grab this tiny ad!
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!