Create a public class called Exceptioner that provides one static method exceptionable. exceptionable accepts a single int as a parameter. You should assert that the int is between 0 and 3, inclusive.
If the int is 0, you should return an IllegalStateException. If it's 1, you should return a NullPointerException. If it's 2, you should return a ArithmeticException. And if it's 3, you should return a IllegalArgumentException.

Answers

Answer 1
Answer:

// Begin class declaration

public class Exceptioner {

   

   // Define the exceptionable method

   public static void exceptionable(int number){

      //check if number is 0.

       if(number == 0) {

           //if it is 0, return an IllegalStateException

           throw new IllegalStateException("number is 0");

       }

      //check if number is 1        

       else if(number == 1) {

           //if it is 1, return a NullPointerException

           throw new NullPointerException("number is 1");

       }

      //check if number is 2        

       else if(number == 2) {

           //if it is 2, return an ArithmeticException

           throw new ArithmeticException("number is 2");

       }

       

      //check if number is 3

       else if(number == 3) {

           //if it is 3, return an IllegalArgumentException

           throw new IllegalArgumentException("number is 3");

       }

   }

}

Sample Output:

Exception in thread "main" java.lang.ArithmeticException: number is 2                                                                          

       at Main.exceptionable(Main.java:26)                                                                                                    

       at Main.main(Main.java:36)  

Explanation:

The code is written in Java with comments explaining important parts of the code.

A sample output for the call of the method with number 2 is also provided. i.e

exception(2)

gives the output provided above.


Related Questions

If you want to continue working on your web page the next day, what should you do?

a. Create a copy of the file and make changes in that new copy

b. Start over from scratch with a new file

c. Once a file has been saved, you cannot change it

d. Reopen the file in your text editor to

Answers

Answer:

d. Reopen the file in your text editor

Answer:

eeeeeeeee

Explanation:

Three reasons why users attach speakers to their computer

Answers

For media sound
For the game's multimedia sound
For essential system sound

How should you present yourself online?

a
Don't think before you share or like something
b
Argue with other people online
c
Think before you post
d
Tag people in photos they may not like

hurry no scammers

Answers

C maybe ......,,,,.....

Answer: C) Think before you post.

Explanation:

There's a very good chance that whatever you post online will remain there indefinitely. So it's best to think about what would happen if you were to post a certain message on a public place. Keep in mind that you should also safeguard against your privacy as well.

d) State any three (3) reasons why users attach speakers to their computer?​

Answers

Answer:

the purpose of speakers is to produce audio output that can be heard by the listener. Speakers are transducers that convert electromagnetic waves into sound waves. The speakers receive audio input from a device such as a computer or an audio receiver.

Explanation: Hope this helps!

The function below takes one parameter: an integer (begin). Complete the function so that it prints every other number starting at begin down to and including 0, each on a separate line. There are two recommended approaches for this: (1) use a for loop over a range statement with a negative step value, or (2) use a while loop, printing and decrementing the value each time.

1 - def countdown_trigger (begin):
2 i = begin
3 while i < 0:
4 print(i)
5 i -= 1 Restore original file

Answers

Answer:

Follows are code to the given question:

def countdown_trigger(begin):#defining a method countdown_trigger that accepts a parameter

   i = begin#defining variable that holds parameter value

   while i >= 0:#defining while loop that check i value greater than equal to0

       print(i)#print i value

       i -= 2  # decreasing i value by 2  

print(countdown_trigger(2))#calling method

Output:

2

0

None

Explanation:

In this code, a method "countdown_trigger" is declared, that accepts "begin" variable value in its parameters, and inside the method "i" declared, that holds parameters values.

By using a while loop, that checks "i" value which is greater than equal to 0, and prints "value" by decreasing a value by 2.

which of the following is an example of how to effectively avoid plagiarism

Answers

Answer:

You didn't list any choices, but in order to avoid all plagiarism, you must focus on rewriting the following script/paragraph in your own words. This could be anything from completely changing the paragraph (not the context) to summarizing the paragraph in your own words.

Answer:

Simon cites anything that he didnt know before he read it in any given source

Explanation:

a p e x

If a system contains 1,000 disk drives, each of which has a 750,000- hour MTBF, which of the following best describes how often a drive failure will occur in that disk farm:

a. once per thousand years
b. once per century, once per decade
c. once per year, once per month
d. once per week
e. once per day
f. once per hour
g. once per minute
h. once per second

Answers

Answer:

once per month

Explanation:

The correct answer is - once per month

Reason -

Probability of 1 failure of 1000 hard disk = 750,000/1000 = 750 hrs

So,

750/24 = 31.25 days

⇒ approximately one in a month.

PLS HELP SO I CAN PASS WILL GIVE BRAINLINESS AND 30 POINTS
Charlie Chaplin is know for developing

a
The Dramedy
b
Early Special Effects
c
Slap-Stick
d
The Prat-Fall
Question 2 (1 point)
Chaplin felt it was important for the audience to

a
turn off their cellphones during the movie.
b
believe the stunts were real by doing them himself.
c
escape from their problems by avoiding difficult topics.
d
have an emotional connection with the characters.
Question 3 (3 points)
Match the silent film with its modern influence

Column A
1.
Metropolis:
Metropolis
2.
The Kid:
The Kid
3.
Nosferatu:
Nosferatu
Column B
a.Freddy Kruger
b.The Simpsons
c.Sharknado
d.Star Wars
Question 4 (1 point)
How did Nosferatu change the Vampire cannon (story)?

a
Vampires are friendly
b
Vampires can be killed by sunlight
c
Vampires can become invisible
d
Vampires can be repelled by garlic
Question 5 (1 point)
Metropolis was the first film to

a
have religious undertones.
b
use special effects.
c
have humanoid robots.
d
use Gothic Imagery.


movies being the kid , nosferatu , and metropolis

Answers

Answer:

a

have religious undertones.

b

use special effects.

c

have humanoid robots.

d

use Gothic Imagery.

Explanation:

What is digital marketing?

Answers

Answer:

Digital marketing is the component of marketing that utilizes internet and online based digital technologies such as desktop computers, mobile phones and other digital media and platforms to promote products and services.

Explanation:

What are some examples and non-examples of digital security?

Answers

Answer:

Devices such as a smart card-based USB token, the SIM card in your cell phone, the secure chip in your contactless payment card or an ePassport are digital security devices

(The Person, Student, Employee, Faculty, and Staff classes) Design a class named Person and its two subclasses named Student and Employee. Make Faculty and Staff subclasses of Employee. A person has a name, address, phone number, and email address.A student has a class status (freshman, sophomore, junior, or senior). Define the status as a constant. An employee has

Answers

Answer:

Explanation:

The following code is written in Java and creates all the classes as requested with their variables, and methods. Each extending to the Person class if needed. Due to technical difficulties I have attached the code as a txt file below, as well as a picture with the test output of calling the Staff class.

your computer has been running slowly and you suspect it because its is low on memory. you review the hardware configuration and find that computer has only 4gb of ram. how can you determine how much memory your computer should have to run properly?​

Answers

By downloading software that is capable of checking live Ram usage/need. GIVE BRAINLIST

You are responsible for a rail convoy of goods consisting of several boxcars. You start the train and after a few minutes you realize that some boxcars are overloaded and weigh too heavily on the rails while others are dangerously light. So you decide to stop the train and spread the weight more evenly so that all the boxcars have exactly the same weight (without changing the total weight). For that you write a program which helps you in the distribution of the weight.
Your program should first read the number of cars to be weighed (integer) followed by the weights of the cars (doubles). Then your program should calculate and display how much weight to add or subtract from each car such that every car has the same weight. The total weight of all of the cars should not change. These additions and subtractions of weights should be displayed with one decimal place. You may assume that there are no more than 50 boxcars.
Example 1
In this example, there are 5 boxcars with different weights summing to 110.0. The ouput shows that we are modifying all the boxcars so that they each carry a weight of 22.0 (which makes a total of 110.0 for the entire train). So we remove 18.0 for the first boxcar, we add 10.0 for the second, we add 2.0 for the third, etc.
Input
5
40.0
12.0
20.0
5. 33.
0
Output
- 18.0
10.0
2.0
17.0
-11.0

Answers

Answer:

The program in C++ is as follows:

#include <iostream>

#include <iomanip>

using namespace std;

int main(){

   int cars;

   cin>>cars;

   double weights[cars];

   double total = 0;

   for(int i = 0; i<cars;i++){

       cin>>weights[i];

       total+=weights[i];    }

   double avg = total/cars;

   for(int i = 0; i<cars;i++){

       cout<<fixed<<setprecision(1)<<avg-weights[i]<<endl;    }

   return 0;

}

Explanation:

This declares the number of cars as integers

   int cars;

This gets input for the number of cars

   cin>>cars;

This declares the weight of the cars as an array of double datatype

   double weights[cars];

This initializes the total weights to 0

   double total = 0;

This iterates through the number of cars

   for(int i = 0; i<cars;i++){

This gets input for each weight

       cin>>weights[i];

This adds up the total weight

       total+=weights[i];    }

This calculates the average weights

   double avg = total/cars;

This iterates through the number of cars

   for(int i = 0; i<cars;i++){

This prints how much weight to be added or subtracted

       cout<<fixed<<setprecision(1)<<avg-weights[i]<<endl;    }

Parts of a computer software

Answers

Answer:

I think application software

utility software

networking software

HURRY- I’ll give 15 points and brainliest answer!!
How do you insert text into a presentation??
By selecting text from the insert menu
By clicking in the task pane and entering text
By clicking in a placeholder and entering text
By drawing a text box clicking in it and entering text
(This answer is multiple select)

Answers

Answer:

the last one the drawing thingy:)))

Which of the following are complete sets of data and are the rows of the table?
Files
Fields
Queries
Records

Answers

Answer:

I think the answer is going to be records

Other Questions
A simulation is done to represent kicking 5 field goals in a single game with a 72% probability of making each one. A 1 represents making the kick and a 0 represents missing the kick. trialresult110101211010300011411111510011 Based on these results, estimate the probability that 3 or more kicks are made. Complete the table below to classify the triangles as scalene or isosceles.TriangleClassification2235109 SOMEBODY HELP PLSS I DONT GET IT Which food belongs to the grains food group?A raisinsB. fromageC. citrouilleD. pain Factorise fully the following x2+2x Round 1.5 to one decimal place I need help, please help Given the description of the firm below, decide whether it applies to monopolistic competition, perfect competition, or both. a. a firm that produces with excess capacity in the long run b. a firm that has market power c. a firm that sets greater than marginal d. a firm that earns zero economic profit in the long isosceles triangle ... area and y intercept comparison. WORTH 100 points !!!! Question 9 of 24What was the effect of unsafe work conditions and pollution during theIndustrial Revolution?A. Middle- and upper-class people moved out of urban areas, causingthose areas to be dominated by the working class.B. Child labor increased as adults left manufacturing jobs in factoriesin favor of agricultural work.C. Governments established regulations to control workenvironments and limit pollution.D. Concerned citizens began to boycott manufactured goods andreturned to a self-sufficient lifestyle. [15 POINTS!!]The diagram below shows a food web.How would the removal of the rabbit population affect the other populations in the ecosystem?A. The field mouse population will decrease.B. The snake population will increaseC. The lizard population will increase.D. The tree population will decrease Hey can you help me fast!!! Name 4 systems that perform the process nutrient absorption Scientists interested in the effect of exercise on the duration of sleep conducted the following study: 180 overweight men were randomly assigned to two groups. One group was instructed to perform aerobic exercise for about an hour per day, and the other group was instructed to continue with their exercise-less routine.The sleep duration of each subject was measured at two points: before the randomization and 101010 weeks after it. Then, the scientists calculated the change in sleep duration for each subject, where a positive value means the duration increased, and a negative value means is decreased.What type of statistical study did scientists use? EASY 10 POINTS AND BRAINLEISTWrite an inequality that represents this situation below. Be sure to define your variable in words. The high school softball team needs to buy T-shirts for their games. The T-shirts cost $8 a piece and they only have $100 to spend. Blues Inc. manufactures jeans in the cutting and sewing process. Jeans are manufactured in 40-jean batch sizes. The cutting time is 5 minutes per jean. The sewing time is 20 minutes per jean. It takes 2 minutes to move a batch of jeans from cutting to sewing. a. Compute the value-added, non-value-added, and total lead time of this process. Value-added lead time fill in the blank 1 minutes Non-value-added lead time fill in the blank 2 minutes Total lead time fill in the blank 3 minutes b. Compute the value-added ratio. Round to one decimal place. 51.Shoveling snow can be extremely taxing because the arms have such a low efficiency in this activity. Suppose a person shoveling a footpath metabolizes food at the rate of 800 W. (a) What is her useful power output? (b) How long will it take her to lift 3000 kg of snow 1.20 m? (This could be the amount of heavy snow on 20 m of footpath.) (c) How much waste heat transfer in kilojoules will she generate in the process? How could technology affect you in the future? The distance between A (-4, 2) and B(4, 2) is. Given that the measurement is in centimeters, find the circumference to the nearest tenth. A: 28.3cmB:56.5cmC:63.6cmD:254.3cm