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
PYTHON:Given the dictionary, d, find the largest key in the dictionary and associate the corresponding value with the variable v
lapo4ka [179]

di = {5: 3, 4: 1, 12: 2}

val_of_max = di[max(di)]

print(val_of_max)

I hope this helps!

4 0
3 years ago
A set of programs that enable the hardware to process data is _____.
Mnenie [13.5K]
The most appropriate answer is C !! software os used for using hardware !!
4 0
3 years ago
You are trying to troubleshoot a desktop power supply issue using a voltmeter. Which of the following options are the MOST commo
vredina [299]

Answer:

The correct answers are: (A) +/- 5V and (B) +/- 12V

Explanation:

First at all, the purpose of the power supply is transforming from AC (Alternating Current) to DC (Direct Current) for use this energy in chips and electronics devices that consume this type of power. Usually the most common DC voltage for electronics is 5V but in your CPU you also have other devices that might going to need more voltage like fan or hard drives thats ´s why 12V is an also an option. Now some other devices are going to need negative sources such -5V or -12V as well.

7 0
2 years ago
A specially formatted encrypted message that validates the information the CA requires to issue a digital certificate is known a
Pavel [41]

Answer:

Certificate Signing Request(CSR).

Explanation:

Certificate Signing Request(CSR):- It is a message that is specially encrypted Which validates the information that is required by CA for the issuing of a digital certificate.

It is the first step towards getting your own SSL certificate.

So we conclude that the answer to this question is Certificate Signing Request (CSR).

5 0
3 years ago
A group of 8 bits is called a... <br> A. hunch <br> B. byte <br> C. dozen <br> D. snack
Mama L [17]
I think that it's called a byte.
5 0
2 years ago
Read 2 more answers
Other questions:
  • trhy356<br>yjetyi46ui y j4yhnpug 2utg[ 2[ 24[ou [o24t
    15·1 answer
  • A file must be ________ before data can be written to or read from it. closed opened buffered initialized none of these
    11·2 answers
  • What procedures are involved in saving a file for the first time?
    10·2 answers
  • A major problem with alcohol adverstising is that
    15·1 answer
  • Explain the main components of a computer system​
    12·1 answer
  • Your wireless network consists of multiple 802.11n access points that are configured as follows: SSID (hidden): CorpNet Security
    8·1 answer
  • One way to initiate a file download from a web page is to
    8·1 answer
  • is a measurement that quantifies how much information can be transmitted over the network. A. Memory B. DMZ C. Bandwidth D. Clou
    10·1 answer
  • Explain the characteristics of a first generation computer​
    8·1 answer
  • If you added the formula =SUM(B1:B5) to a spreadsheet, what would it do?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!