1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
tiny-mole [99]
3 years ago
11

1. Write an application that throws and catches an ArithmeticException when you attempt to take the square root of a negative va

lue. Prompt the user for an input value and try the Math.sqrt() method on it. The application either displays the square root or catches the thrown Exception and displays an appropriate message. Save the file as SqrtException.java.
2. Create a ProductException class whose constructor receives a String that
consists of a product number and price. Save the file as ProductException.java.
Create a Product class with two fields, productNum and price. The Product
constructor requires values for both fields. Upon construction, throw a
ProductException if the product number does not consist of three digits, if the
price is less than $0.01, or if the price is over $1,000. Save the class as Product.java.
Write an application that establishes at least four Product objects with valid and invalid values. Display an appropriate message when a Product object is created
successfully and when one is not. Save the file as ThrowProductException.java.
Computers and Technology
1 answer:
Inessa05 [86]3 years ago
4 0

Answer:

Hence the answer is given as follows,

You might be interested in
____ allows you to add formatting such as shapes and colors to text
Alla [95]
Css also known as cascading style sheets which is a program used to design a webpage and color in the texts of a body.
6 0
3 years ago
Provide the definition for each of the following structures and unions:
galben [10]

Answer:

a)

struct inventory  // structure inventory

{

char partName[ 30 ];  // char array

int partNumber;  // variable partNumber

float price;  // FLOAT VARIABLE PRICE

int stock ;  // INT VARIABLE STOCK

int reorder;  // INTEGER VARIABLE RECORDER

};

b)

union data // structure union

{

char c;  // char variable

short s; // short variable

long b; //

long variable float f ;  // float variable

double d ; // double variable

};

c)

struct address  // structure address

{

char streetAddress[ 25 ]; // character array

char city[ 20 ]; // variable char

char  state[ 3 ] ; // state array

char  zipCode[ 6 ] ; // zipcode array

};

d)

structure student  // structure student

{

char firstName[ 15 ]; // array first name

char  lastName[ 15 ] ;  // array last name

struct address * ;  // holding the home address

};

e)

struct test

{

unsigned a:1, b:1, c:1, d:1, e:1, f:1, g:1, h:1, i:1, j:1, k:1, l:1, m:1, n:1, o:1, p:1;

}; // prototype test assign value

Explanation:

Following are the description of the above part

a)

  • By using the struct keyword we declared the structure .In the part (a) we declared the struct  "inventory".In this structure we char array "partName " of size 30 .
  • We holding the 3 int variable "partNumber" , "stock" and "reorder." and 1 float variable i.e "price ".

b)

  • By using the union keyword we declared the union .In the part (b) we created the union .
  • Inside that union we holding different types of datatype that are mention in the question .

C)

  • By using the struct keyword we declared the structure  .In the part (c) we created the structure.
  • Inside that structure we holding array of character of variable "streetAddress","city","state" and "zipcode" by using char array .

d)

  • By using the struct keyword we declared the structure .
  • In this we declared array of "firstname" and "lastname" of char datatype .
  • In the last we create a structure address by using the pointer following by struct address

e)

In the part e we created the test that contain unsigned value of thhe 16 bit and 1 width

8 0
3 years ago
Explain at least one reason why programming languages have functions
Salsk061 [2.6K]
With functions we can separate different parts of our code. each functions implements a single logical part of the program.

for example sqrt() function does square root. so we can use it in different programs, because it's a stand-alone component.

6 0
3 years ago
Which of these Logic Statement's are correct for the following diagram? *
Solnce55 [7]

Answer:

A AND B OR C

Explanation:

7 0
3 years ago
Which of the following is least likely to be a scientific experiment?
enot [183]
It would be the last one, because she isn't recording any type of data over what she is doing and she isn't observing it at all. She simply trimmed the stems of a bouquet of flowers. However, the other options insist that they are recording data and observing, like you would do when performing an experiment. I hope this helps! :)
8 0
3 years ago
Read 2 more answers
Other questions:
  • Given three dictionaries, associated with the variables, canadian_capitals, mexican_capitals, and us_capitals, that map province
    11·1 answer
  • An expression that has correctly paired delimiters is called a(n)
    6·1 answer
  • ________ is the presentation of information to the user and the acceptance of the user’s commands. a.data storageb.data access l
    7·1 answer
  • What problem does chlorofluorocarbon (CFC) create?
    5·1 answer
  • Which is most likely a presentation file?
    8·1 answer
  • Is mmorpg an example of virtual community
    5·2 answers
  • which of these variable declarations will the variable remain uninitialized unless it is explicitly initialized?1)Declaration of
    5·1 answer
  • A pre-design document you can use to create a new project quickly
    5·1 answer
  • Design a class named Employee. The class should keep the following information in member variables:
    5·1 answer
  • The derivative of <br><img src="https://tex.z-dn.net/?f=ln%20%5C%3A%20%20%7Cx%7C%20" id="TexFormula1" title="ln \: |x| " alt="l
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!