Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Suppose that you have access to the function below. This function takes System.in as an argument and determines whether the input falls into one of
Suppose that you have access to the function below. This function takes System.in as an argument and determines whether the input falls into one of three categories. It then returns the category of input. For the purposes of this question, we don't really care about what exactly this function does when it works correctly or what these categories mean.
Returns whether the given input is of type or
@returns or based on the data from in
private static int categorizeInputStream in
Further, suppose that the above function can also throw one of two different kinds of exceptions:
The function throws a BadInputException if the user input is bad in any way
The function throws a MultipleCategoryException if the user input could be categorized in more than one way. This is a special kind of bad input, and as such this is a subclass of BadInputException
Provide a snippet of code that does the following:
Attempt to categorize user input. If successful, print a nice message to the console explaining what category the input falls into
If the method generates an exception, we should print a nice message to the console explaining what went wrong at least as far as we know HINT: pay attention to the relationship between the two different kinds of exceptions.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started