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
Eduardwww [97]
3 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]3 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 Advantage does a voltmeter have over a noncontact voltage indicator when testing for voltage
galina1969 [7]

Answer:

Obviously you shouldn't rely just on the meter for your safety. You'd disconnect wall fuses or kill main switches before you start, using the meter just gives you some extra protection: with the meter you might notice for example that you've disconnected the wrong fuse and the unit is still live.

Explanation:

Hope it helps! :)

5 0
2 years ago
technician a says that a gasoline engine is designed to operate at near or maximum speed for long periods without damage. techni
Vinil7 [7]

we can see that the correct person here will be Technician B who says that a diesel engine is designed to operate at near or maximum speed for long periods without damage.

<h3>What is a diesel engine?</h3>

A diesel engine is actually known to be an engine that makes use of diesel as its fuel. In other words, diesel engines run on diesel.

We see here that a diesel engine is actually designed to work for a very time on near or maximum speed without damage. This is true because the diesel fuel has that strength.

Also, diesel engines may be designed as two or four stroke cycles.

Learn more about diesel engine on brainly.com/question/13146091

#SPJ1

3 0
2 years ago
A power of 100 kW (105 W) is delivered to the other side of a city by a pair of power lines, between which the voltage is 12,000
OLga [1]

Answer:

I = 8.3 Amp

potential drop = 83 V

Explanation:

Power = 100 KW

V = 12,000 V

R = 10 ohms

a)

Calculate current I in each wire:

P = I*V

I = P / V

I = 100 / 12 = 8.333 A

b)

Calculate potential drop in each wire:

V = I*R

V = (8.3) * (10)

V = 83 V

4 0
3 years ago
A heat pump is used to warm a building in the winter. This system implements an ideal vapor-compression cycle with R-134a as the
Marrrta [24]

Answer:

See attachment for detailed answer.

Explanation:

Download pdf
5 0
3 years ago
A fuel gas containing 45.00 mole% methane and the balance ethane is burned completely with pure oxygen at 25.00 degree C, and th
Dennis_Churaev [7]

Answer:

A)

- Q ( kw ) for vapor =  -1258.05 kw

- Q ( kw ) for liquid = -1146.3 kw

B )

- Q ( kj ) for vapor  = -1258.05 kJ

- Q ( KJ ) for liquid = - 1146.3 KJ

Explanation:

Given data :

45.00 % mole of methane

55.00 % of ethane

attached below is a detailed solution

A) calculate - Q(kw)

- Q ( kw ) for vapor =  -1258.05 kw

- Q ( kw ) for liquid = -1146.3 kw

B ) calculate  - Q ( KJ )

- Q ( kj ) for vapor  = -1258.05 kJ

- Q ( KJ ) for liquid = - 1146.3 KJ

since combustion takes place in a constant-volume batch reactor

7 0
3 years ago
Other questions:
  • Lydia is the CEO for a large pharmaceutical manufacturer. Her company is in the final stages of FDA
    12·1 answer
  • Why is my lawn mower not starting?
    9·1 answer
  • - The four leading causes of death in the
    5·2 answers
  • Consider a fully developed laminar flow in a circular pipe. The velocity at R/2 (midway between the wall surface and the centerl
    6·1 answer
  • A 4-pole, 3-phase induction motor operates from a supply whose frequency is 60 Hz. calculate: 1- the speed at which the magnetic
    6·1 answer
  • Before accurate distance standards, a cubit was the length of whose forearm?
    5·1 answer
  • The temperature controller for a clothes dryer consists of a bimetallic switch mounted on an electrical heater attached to a wal
    12·1 answer
  • A proposed embankment fill requires 7100 ft of compacted soil. The void ratio of the compacted fill is specified as 0.5. Four bo
    10·1 answer
  • 3<br> Current is measured in units called
    6·2 answers
  • How does energy transition from one form to another as water moves from behind a dam to downstream of a dam?.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!