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]
3 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]3 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
How can you tell if your car is overheating?
Nitella [24]
A) your temp gauge is moving into red
4 0
3 years ago
Read 2 more answers
Which of the following is something that would NOT appear in the Reviewing pane?
Sophie [7]

Answer:

A

Explanation:

7 0
2 years ago
What is log in and log out?
Brums [2.3K]
Log in is the feature that allows you to access your electronic account in a website, database or other, also a bank account. Your username and password are stored in cookies  (files that websites use and are stored in your browser) for the session. This is true if we talk about websites.

When you're done, you log out from your account, you disconnect. Cookies are cleared (for websites) and you're out.
8 0
3 years ago
To delete a row, you must first___.
Phantasy [73]
Select the row or select the adjacent column
8 0
3 years ago
Read 2 more answers
Which of the following BEST describes the difference between an intranet and internet?
Studentka2010 [4]
The answer would be B, as the internet is available to anyone who knows their IP address, whereas an intranet, upon being connected to the internet, would remain hidden behind a firewall.  Have a nice day, hope this helps. :)
7 0
3 years ago
Other questions:
  • Cloud Kicks is undergoing a GDPR-focused implementation to ensure access to personal information data is limited to only users w
    7·1 answer
  • A very simple device that connects network components and sends packets of data to all other connected devices is called a _____
    5·1 answer
  • You have just installed a new sound card in your system, and Windows says the card installed with no errors. When you plug up th
    5·1 answer
  • Andy wants to install a new Internet connection. He wants to take the fastest he can get. What are the maximum speeds for the fo
    9·1 answer
  • Your ___ can provide hardware firewall protection for your home network where it connects to the ISP's network, just as ISP netw
    12·1 answer
  • The linear programming ingredient or blending problem model allows one to include not only the cost of the resource, but also th
    14·1 answer
  • Connect 5 LEDs with any random colors. Iteratively, turn ON 1 to 5 LED(s) that will take 5 iterations in total, and in every ite
    6·1 answer
  • What is the mest gun in pixel gun 3d imma give you brainliest
    14·2 answers
  • It's important to understand that even information systems that do not use computers
    14·1 answer
  • What facilitates the automation and management of business processes and controls the movement of work through the business proc
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!