Forums Register Login

How to handle exceptions?

+Pie Number of slices to send: Send
I am learning so please bear with me.

I'm working on this program for exception handling.

The program asks the user for a number between 1-100. If the number is within that range it simply prints it out. If the number is too high, too low, or a negative it throws an error message. Each exception of too high, too low, neg, should be a separate class that the driver program checks. I also need a "verify" class that checks the number entered is within the range by use of a constructor that has two int parameters, first int is low range of 1 and second int is high number of 100.

This is what I have so far...please don't be too harsh I'm new at this...what I don't understand is how the highlow class "calls" the error checking and basically what needs to be defined in those classes...any help is greatly appreciated!

+Pie Number of slices to send: Send
There are several things wrong in this programme. Please see this for your reference and correct the programme accordingly.

Right now your code can't compile. You can check the mentioned tutorials for right usage.
+Pie Number of slices to send: Send
Welcome to the Ranch

Start by going through the Java® Tutorials. The hard part of handling Exceptions is working out two things:-
  • 1: Where is it best to handle this Exception?
  • 2: What is the best action to take if this Exception occurs?
  • +Pie Number of slices to send: Send
    I see I have given you the same link that Tushar Goel has already given you.
    Catch Ernie! Catch the egg! And catch this tiny ad too:
    a bit of art, as a gift, the permaculture playing cards
    https://gardener-gift.com


    reply
    reply
    This thread has been viewed 442 times.
    Similar Threads
    Java Guessing Game - OutOfMemoryError
    clues on how to exit this while loop, please?
    Cannot throw exception
    Loop Issues
    Map<Integer, Integer> intMap = new Hashtable<Integer, Integer>(); does not work
    More...

    All times above are in ranch (not your local) time.
    The current ranch time is
    Mar 29, 2024 01:13:10.