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
To achieve the maximum confidentiality and integrity found in a completely secure information system would require that the syst
fgiga [73]

Answer:

The answer is "Option a".

Explanation:

Privacy is a set of rules, which limiting access to the data, and integrity ensures impartiality, accuracy, and reliability is assured to ensure, which authorized persons can have secure access to the data.

The system needs no access for everyone to achieve its secrecy and integrity contained in a completely safe data system, that's why the given statement is "true".

5 0
3 years ago
What can a human till do better and fater than any Machine Learning (ML) olution?
Gemiola [76]

Judge the quality of any given data can a human till do better and fater than any Machine Learning (ML).

<h3>What is Machine Learning (ML)?</h3>
  • Switch between fields of expertise. a thorough understanding of the facts' meaning. Check the veracity of any information that is provided.
  • According to some scientists, AI will replace jobs with a single output. A mental task may also be mechanized in the future if it can be finished by a person in less than a second.
  • Expressing empathy, making others feel good, taking care of others, expressing feelings and vulnerability in a sympathetic way, and making people laugh are all examples of being creative and artistic for the purpose of being creative. The personal touch is important in most occupations and, in certain cases, it completes the task entirely.
  • Machines can perform as well as or better than humans in some tasks, despite their slower rate of development.

To learn more about Machine Learning (ML) refert to:

brainly.com/question/25523571

#SPJ4

5 0
1 year ago
A switch that is configured to use the Spanning Tree Protocol will place a port in ____________ mode if sending traffic to it ma
Rashid [163]

Answer:

Blocking Mode    

Explanation:

Spanning Tree Protocol is used to allow path redundancy in the network without creating cycles/circles also called loops.

When two parts of the switched network are connected via two or more Layer 2 switches this result in a loop.

This affects the performance of the network as the result of broadcast packets flooding.

STP puts one port of the switch to forwarding mode and the rest of the ports within the same part of the network to the blocking mode to avoid broadcast packet flooding. STP puts all the ports that are allowing redundant paths to blocking mode and the one port that is left after this is placed in forward mode.

Spanning Tree Algorithm is used by STP to determine the optimal path  of switch to the network.

Bridge Protocol Data Units are used to share the information about the optimal path determined by the spanning tree algorithm with other switches.

This information helps STP to eliminate the redundant paths.

So this is how STP allows only one active path to the destination while blocking all other paths to avoid switching loop.

6 0
3 years ago
Write a recursive function that returns 1 if an array of size n is in sorted order and 0 otherwise. Note: If array a stores 3, 6
Tanzania [10]

Answer:

Here the code is given as follows,

Explanation:

Code:-

#include <stdio.h>  

int isSorted(int *array, int n) {

   if (n <= 1) {

       return 1;

   } else {

       return isSorted(array, n-1) && array[n-2] <= array[n-1];

   }

}  

int main() {

   int arr1[] = {3, 6, 7, 7, 12}, size1 = 5;

   int arr2[] = {3, 4, 9, 8}, size2 = 4;  

   printf("%d\n", isSorted(arr1, size1));

   printf("%d\n", isSorted(arr2, size2));

   return 0;

}

Output:-

4 0
3 years ago
What is a possible explanation for the issue described below? A user reports that ever since she or he began creating animations
Marat540 [252]
VRAM because VRAM is used for graphic intensive workloads
8 0
3 years ago
Read 2 more answers
Other questions:
  • Achieving a degree in computer forensics, information technology, or even information systems can provide a strong foundation in
    11·1 answer
  • Kevin wants an application that will help him create a website as well as publish it. What application can he use?
    9·1 answer
  • Jason is creating a webpage on the basic parts of a camera. He has to use a mix of both images and content for the web page to h
    11·1 answer
  • True / False
    5·1 answer
  • Operating systems are often written in ________, a very low-level computer programming language that allows the computer to oper
    10·1 answer
  • Select the statement that best describes the function of the cell wall. O it gives shape to plants cells. O it produces food fro
    14·1 answer
  • How are Action Buttons different than hyperlinks?
    8·1 answer
  • L00000000000000000000000000000000000000000000000000000000l they b00ty tickled
    6·2 answers
  • What is the largest place value in a 12 bit binary number?
    10·1 answer
  • Input two numbers and print their sum products difference division and remainder​
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!