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
padilas [110]
3 years ago
11

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. The catch block forces the number to 0 and displays Value entered cannot be converted to a floating-point number. Following the catch block, display the number.
Computers and Technology
1 answer:
Andrei [34K]3 years ago
3 0

Answer:

  1. import java.util.Scanner;
  2. public class Main {
  3.    public static void main(String[] args) {
  4.        Scanner input = new Scanner(System.in);
  5.        String numStr = input.nextLine();
  6.        double num;
  7.        try{
  8.            num = Double.parseDouble(numStr);
  9.        }
  10.        catch(NumberFormatException e){
  11.            num = 0;
  12.            System.out.println("Value entered cannot be converted to a floating point number.");
  13.        }
  14.    }
  15. }

Explanation:

The solution code is written in Java.

Firstly, we create a Scanner object and prompt user to input a number (Line 5-6). Next, we create a try -catch block and place the parseDouble inside the try block. If the input is invalid (e.g. "abc"), a NumberFormatException error will be thrown and captured and set the num to 0 and display the error message (Line 11 - 13).  

You might be interested in
How can artificial intelligence be used in learning science?
tiny-mole [99]

Artificial intelligence can be used to help science students research and verify their research. It is also a very interesting topic to study in general.

Hope that helped!!! k

5 0
3 years ago
Data owners ensure that only the access that is needed to perform day-to-day operations is granted and that duties are separated
Akimi4 [234]

Answer:

True

Explanation:

As employees might be accessing business/client data, security of data access is a topmost priority.

8 0
3 years ago
True or False: Busy people prefer your email as one big paragraph rather than adding line breaks for new sections/paragraphs. Yo
Rainbow [258]

Based on the information given regarding how email should be written, it can be deduced that the statement is false.

<h3>Importance of emails.</h3>

It should be noted that email is an important method that is used for communication. It's fast, cheap, and easily accessible.

People do not prefer your email as one big paragraph rather, it's important to add line breaks for new sections or paragraphs. This is essential to convey the information effectively.

In conclusion, using email us also beneficial for businesses to reach their customers.

Learn more about emails on:

brainly.com/question/24558412

3 0
2 years ago
Which of the following indicates the main benefit of having a larger hard drive on a computer
dem82 [27]
I would say the primary Beni fit is more space for storage , but also it does effect the speed eventually. If your hard drive is almost full, everything will be slower
8 0
3 years ago
Sequential and direct access are two methods to locate data in memory. Discuss why major devices now a days use direct access? H
djverab [1.8K]

Answer:

Direct data access reduces the speed of retrieving data from memory or storage. Retrieving data and storing it in a cache memory provides direct access to data in the storage.

Explanation:

Sequential memory access, as the name implies, goes through the memory length location in search of the specified data. Direct memory access, provides a memory location index for direct retrieval of data.

Examples of direct and sequential memory access are RAM and tapes respectively. Data in sequential memory access can be access directly by getting data in advance and storing them in cache memory for direct access by the processor.

3 0
3 years ago
Other questions:
  • How to remove a channel from favorite list on suddenlink?
    15·1 answer
  • What is the formula for calculating the average of cells<br> C2 through C30?
    15·1 answer
  • The title of a Web page is the text that appears on the title bar and taskbar of the browser window. *
    13·1 answer
  • The indent buttons on the home tab allow you to increase or decrease paragraph indenting in increments of ____ inches.
    5·1 answer
  • What is a feature of webmail
    13·1 answer
  • Suppose that we want to multiply 500 matrices and we use the optimal parenthesization computed by the MATRIX-CHAIN-ORDER functio
    13·2 answers
  • Modify class Time2 of fig 8.5, (which is split into four pictures) to include a tick method that increments the time stored in a
    8·1 answer
  • The instructions in a program, when expressed in Python, ...
    7·1 answer
  • HELP MEEE PLEASE!!!
    11·1 answer
  • You have two identical print devices that are set up in a work room. Currently, the Windows print server has two printers config
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!