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]
2 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]2 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
Operators allow you to compare values then make decisions (Scratch Coding)
patriot [66]

Explanation:

ok thnka

4 0
2 years ago
Read 2 more answers
If there is a need to write code in order to help the player move through the game which team member would create this code?
charle [14.2K]

Answer:

Run code, and then check the code

Explanation:

8 0
2 years ago
Pleasee help in this ​
lutik1710 [3]

Answer:

virtual reality glasses

In a VR setting, students can interact with what they see as if they were really there. In addition to providing students with immersive learning experiences, other benefits of virtual reality in education include the ability to inspire students' creativity and spark their imaginations.

Virtual reality headsets are being currently used as a means to train medical students for surgery. It allows them to perform essential procedures in a virtual, controlled environment. Students perform surgeries on virtual patients, which allows them to acquire the skills needed to perform surgeries on real patients.

7 0
3 years ago
The ________ utility automatically creates duplicates of your libraries, desktops, contacts, and favorites to another storage lo
olchik [2.2K]

I guess the best option is B.

The file history utility automatically creates duplicates of your libraries, desktops, contacts, and favorites to another storage location.


7 0
3 years ago
Investigations involving the preservation, identification, extraction, documentation, and interpretation of computer media for e
Goryan [66]

Answer:

The correct answer to the following question will be "Digital Forensics".

Explanation:

  • Digital forensics is a field of forensics that involves the analysis and retrieval of materials found in electronic devices, sometimes related to cybercrime.
  • The objective of digital forensics methodologies would be to check, maintain and evaluate evidence on computing systems to find possible evidence for a trial. In the initial days of computing, an individual investigator could process files because the power consumption was so small.

Therefore, Digital Forensic is the right answer.

7 0
3 years ago
Other questions:
  • The ability to share information between programs is what
    8·1 answer
  • Could this be restored? And is it worth the money it’d take?
    9·2 answers
  • Is the core of an operating system that controls its basic functions.
    9·1 answer
  • Suggest me a website or any channel for learning coding.
    5·1 answer
  • cellPhoneBill(m,tx)Write the function cellPhoneBill()that takes two int m and txas input and returns a float.The function takes
    11·1 answer
  • A variable that can have values only in the range 0 to 65535 is a :
    5·1 answer
  • You administer a Microsoft SQL Server environment. You purchase a new server and plan to migrate your database from SQL Server 2
    8·1 answer
  • You work for a company that builds custom PCs for select clients. You are training a new employee to evaluate and select appropr
    13·1 answer
  • Select the correct answers
    9·1 answer
  • Hmm what should i do with this information
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!