Answered step by step
Verified Expert Solution
Link Copied!

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 1,2, or 3
*
* @returns [1,2, or 3 based on the data from in]
*/
private static int categorize(InputStream in)
Further, suppose that the above function can also throw one of two different kinds of exceptions:
1. The function throws a BadInputException if the user input is bad in any way
2. 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:
1. Attempt to categorize user input. If successful, print a nice message to the console explaining what category the input falls into
2. 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Administrator Limited Edition

Authors: Martif Way

1st Edition

B0CGG89N8Z

Students also viewed these Databases questions

Question

10:16 AM Sun Jan 29 Answered: 1 week ago

Answered: 1 week ago

Question

What is the basis for Security Concerns in Cloud Computing?

Answered: 1 week ago

Question

Describe the three main Cloud Computing Environments.

Answered: 1 week ago