answer.
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
Eduardwww [97]
2 years ago
14

The Double.parseDouble() method requires a String argument, but it fails if the String cannot be converted to a floating-point n

umber. Write an application in which you try accepting a double input from a user and catch a NumberFormatException if one is thrown. Te catch block forces the number to 0 and displays an appropriate error message. Following the catch block, display the number. Save the fle as TryToParseDouble.java.
Engineering
1 answer:
LuckyWell [14K]2 years ago
5 0

Answer:

  1. import java.util.Scanner;
  2. public class TryToParseDouble {
  3.    public static void main(String[] args) {
  4.        Scanner input = new Scanner(System.in);
  5.        double num;
  6.        try{
  7.            System.out.print("Input a number: ");
  8.            num = Double.parseDouble(input.nextLine());
  9.        }catch(NumberFormatException e){
  10.            num = 0;
  11.            System.out.println("Invalid input! It should be a number in double type");
  12.        }
  13.        System.out.println(num);
  14.    }
  15. }

Explanation:

Firstly, create a Scanner object to get user input (Line 5).

Next, create a try block and prompt user to input a number and use Double.parseDouble() method to convert the input to double type in the block (Line 8-10).

Next, create a catch block to catch a NumberFormatException. In the Catch block, set the num to zero and then print out a message to inform user about the invalid input (Line 12-14).

Lastly, display the number (Line 16).

You might be interested in
What is the linear distance traveled in one revolution of a 36-inch wheel
Afina-wow [57]

Answer:

  36π inches ≈ 113.0973 inches

Explanation:

The circumference of the wheel is pi times its diameter.

  C = πd

  C = π(36 in) = 36π in ≈ 113.0973 in

The distance around the wheel is 36π inches, about 113.0973 inches.

7 0
2 years ago
Evan notices a small fire in his workplace. Since the fire is small and the atmosphere is not smoky he decides to fight the fire
Norma-Jean [14]

Answer:

not calling the firemean

Explanation:

7 0
2 years ago
Explain why failure of this garden hose occurred near its end and why the tear occurred along its length. Use numerical values t
alukav5142 [94]

Answer:

  • hoop stress
  • longitudinal stress
  • material used

all this could led to the failure of the garden hose and the tear along the length

Explanation:

For the flow of water to occur in any equipment, water has to flow from a high pressure to a low pressure. considering the pipe, water is flowing at a constant pressure of 30 psi inside the pipe which is assumed to be higher than the allowable operating pressure of the pipe. but the greatest change in pressure will occur at the end of the hose because at that point the water is trying to leave the hose into the atmosphere, therefore the great change in pressure along the length of the hose closest to the end of the hose will cause a tear there. also the other factors that might lead to the failure of the garden hose includes :

hoop stress ( which acts along the circumference of the pipe):

αh = \frac{PD}{2T}     EQUATION 1

and Longitudinal stress ( acting along the length of the pipe )

αl = \frac{PD}{4T}       EQUATION 2

where p = water pressure inside the hose

          d = diameter of hose, T = thickness of hose

we can as well attribute the failure of the hose to the material used in making the hose .

assume for a thin cylindrical pipe material used to be

\frac{D}{T} ≥  20

insert this value into equation 1

αh = \frac{20 *30}{2}  = 60/2 = 30 psi

the allowable hoop stress was developed by the material which could have also led to the failure of the garden hose

8 0
2 years ago
Universal Containers has a junction object called "Job Production Facility". With 2 master-detail relationships to the Job and P
alexdok [17]

Answer:

C. The user will not be able to see the junction object records or the field values.

Explanation:

For the profile of the user to give access permission such as create and read to the job without granting access permission to the production facility object, the value of the field or records of the junction object will not be seen by the user. This is one of the necessary criteria or principle for the universal container with a junction object.

3 0
2 years ago
The legend that Benjamin Franklin flew a kite as a storm approached is only a legend—he was neither stupid nor suicidal. Suppose
Delicious77 [7]

Answer: 0.93 mA

Explanation:

In order to calculate the current passing through the water layer, as we have the potential difference between the ends of the string as a given, assuming that we can apply Ohm’s law, we need to calculate the resistance of the water layer.

We can express the resistance as follows:

R = ρ.L/A

In order to calculate the area A, we can assume that the string is a cylinder with a circular cross-section, so the Area of the water layer can be written as follows:

A= π(r22 – r12) = π( (0.0025)2-(0.002)2 ) m2 = 7.07 . 10-6 m2

Replacing by the values, we get R as follows:

R = 1.4 1010 Ω

Applying Ohm’s Law, and solving for the current I:

I = V/R = 130 106 V / 1.4 1010 Ω = 0.93 mA

7 0
2 years ago
Other questions:
  • Compute the mass fractions of α ferrite and cementite in pearlite. Assume T=726⁢ C∘.
    15·1 answer
  • A 1020 CD steel shaft is to transmit 15 kW while rotating at 1750 rpm. Determine the minimum diameter for the shaft to provide a
    10·1 answer
  • A binary star system consists of two stars of masses m1m1m_1 and m2m2m_2. The stars, which gravitationally attract each other, r
    9·1 answer
  • The velocity of a particle which moves along the s-axis is given by v = 2-4t+5t^(3/2), where t is in seconds and v is in meters
    11·2 answers
  • air at 600 kPa, 330 K enters a well-insulated, horizontal pipe having a diameter of 1.2 cm and exits at 120 kPa, 300 K. Applying
    10·1 answer
  • Technician A says that TSBs are typically updates to the owner's manual. Technician B says that TSBs are generally
    11·1 answer
  • What should always be done before beginning any diagnosis?
    9·1 answer
  • Alicia had to get over her fear of heights in order to become comfortable maintaining the generators in wind turbines. professio
    7·1 answer
  • How does Accenture generate value for clients through Agile and DevOps?
    15·2 answers
  • George is replacing a burned out resistor in a circuit board. The board has a 10, a 20, and a 40 on resistor, all in parallel. W
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!