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
BaLLatris [955]
4 years ago
13

Code example 5-1 import java.util.Scanner; import java.text.NumberFormat; public class WeightConverter { public static void main

(String[] args) { Scanner sc = new Scanner(System.in); String prompt = "Enter weight in lbs: "; boolean isValid = false; double weightInPounds = 0.0; while (!isValid) { weightInPounds = getDouble(sc, prompt); if (weightInPounds > 0) { isValid = true; } else { System.out.println("Weight must be greater than 0."); } } double weightInKilos = weightInPounds / 2.2; NumberFormat nf = NumberFormat.getNumberInstance(); nf.setMaximumFractionDigits(2); String message = weightInPounds + " lbs\nequals\n" + nf.format(weightInKilos) + " kgs\n"; System.out.print(message); } public static double getDouble(Scanner sc, String prompt) { double d = 0.0; boolean isValid = false; while (!isValid) { System.out.print(prompt); if (sc.hasNextDouble()) { d = sc.nextDouble(); isValid = true; } else { System.out.println ("Error! Invalid decimal value. Try again."); } sc.nextLine(); } return d; } } (Refer to code example 5-1.) If the user enters "two hundred" at the console prompt, what does the code do? a. displays an error message from the main() method b. displays an error message from the getDouble() method c. figures the weight in kilograms d. throws an InputMismatchException
Computers and Technology
1 answer:
Trava [24]4 years ago
4 0

Answer:

It displays an error message from the getDouble() method

Explanation:

The above would be the result because of the following

1. Variable d is declared as a double variable and should be used as such.

2. The getDouble() method is also defined to handle double variables only.

When the program tries to accept at

weightInPounds = getDouble(sc, prompt);

The getDouble method is called immediately and since the value

"two hundred" entered in string, it can't handle this data type and it (the getDouble method) will display an error message

You might be interested in
In the code that follows, prompt is a/an ____________________________.
Delvig [45]
Var<span> person = prompt(</span>"Please enter your name"<span>, </span>"Name Field"<span>);
<span>Though, this might be in the wrong context.</span></span>
3 0
4 years ago
Air bags expand at up to __________ mph. A. 70 B. 100 C. 150 D. 200
almond37 [142]
Airbags expand
D. 200 mph
7 0
3 years ago
All of these issues are results of data integrity problems except ________.
Dvinal [7]

If there is an issue with the integrity of data the only one that will not be an issue is; The system will give users too much information.

<h3>What is Data Security?</h3>

Data Security is defined as a security service that deals with identifying any alteration to the data. This is as a result of the data getting modified by an unauthorized entity either intentionally or accidentally.

Now, data security is also called data integrity is simply the safety of data and from the options given if there is an issue with the integrity of data the only one that will not be an issue is  the system will give users too much information. because it is not a function of breach of data security.

Read more about data security at; brainly.com/question/4688296

8 0
3 years ago
Given the following classes and their objects:
Andrej [43]

Answer:

The answer is "Option b"

Explanation:

In the given code three-class C1, C2, and C3 are declared, in which C2  and C3 extend the class C1. In the next line, C2 and C3 object are created, that is c2 and c3. and in the last line c2 class object holds two-class C2, C1, and one object c3 value, this code will give runtime error because it can't cast object from sibling class, and wrong choices can be defined as follows:

  • In option a, It is not correct because it can't cast c3 object into c2 object.
  • In option c, It is not correct because it performs multiple casting in nested forms.
  • In option d, It is wrong because the statement is not correct.
3 0
4 years ago
Mark is learning to make logos. Once he finishes learning, he plans to freelance. Which software is most preferred to create art
MAVERICK [17]
Abode Illustrator helps to design logos in professional way
8 0
3 years ago
Other questions:
  • When a program lets the user know that an invalid choice has been made, this is known as:?
    6·1 answer
  • True or False? In cloud computing, the term "Measured service" refers to a billing model in which gaining access to resources do
    12·1 answer
  • An executive at an online video company wants to look over usage data from the previous month. The company has data from
    15·2 answers
  • The trade winds are the dominant surface winds from the subtropics to high latitudes. 1. True 2. False
    7·1 answer
  • What controls network connectivity such as Wi-Fi and the GPS locator in a mobile device?
    8·1 answer
  • Which two pieces of information must be provided when saving a file for the first time in Wordpad?____.
    8·1 answer
  • Assume that the demand curve for DVD players shifts to the left and the supply curve for DVD players shifts to the right, but th
    6·1 answer
  • Two-dimensional random walk (20 points). A two-dimensional random walk simulates the behavior of a particle moving in a grid of
    14·1 answer
  • Does artificial intelligence have a place in our society why or why not
    5·2 answers
  • Any one know??please let me know
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!