subject

Create a new Java file and: 1. Create an exception class named NegativeNumberException extended from the class
Exception. This class should contain a parameterless constructor to call the Exception
class constructor with the message “You should enter a positive number”.
2. Create a class named exercise3 that contains:
a) A method named M1 that accepts a double variable as argument and returns
its square root. The method should throw the NegativeNumberException
exception defined above.
b) The main method to prompt the user to enter a number and then to call the
method M1 (insert a try-catch block to handle the NegativeNumberException
exception)

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 14:00
What are procedures that keep a data base current
Answers: 1
question
Computers and Technology, 22.06.2019 19:20
Consider the following code snippet: #ifndef cashregister_h#define cashregister_hconst double max_balance = 6000000.0; class cashregister{public: cashregister(); cashregister(double new_balance); void set_balance(double new_balance); double get_balance() const; private: double balance[12]; }; double get_monthly_balance(cashregister bk, int month); #endifwhich of the following is correct? a)the header file is correct as given.b)the definition of max_balance should be removed since header files should not contain constants.c)the definition of cashregister should be removed since header files should not contain class definitions.d)the body of the get_monthly_balance function should be added to the header file.
Answers: 1
question
Computers and Technology, 22.06.2019 23:30
Which of the following is not a symptom of chronic fatigue syndrome
Answers: 2
question
Computers and Technology, 23.06.2019 05:30
Sally is editing her science report about living things. she needs to copy a paragraph from her original report. order the steps sally needs to do to copy the text to her new document.
Answers: 1
You know the right answer?
Create a new Java file and: 1. Create an exception class named NegativeNumberException extended fro...
Questions
question
Mathematics, 12.03.2021 19:30
question
Mathematics, 12.03.2021 19:30
question
Mathematics, 12.03.2021 19:30
question
Mathematics, 12.03.2021 19:30
question
Mathematics, 12.03.2021 19:30
Questions on the website: 13722360