subject

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

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 11:30
What does a cascading style sheet resolve a conflict over rules for an element? a. the rule affecting the most content wins b. the rule affecting the most content loses c. the rule with the most specific selector loses d. the rule with the most specific selector wins
Answers: 2
question
Computers and Technology, 23.06.2019 03:00
State 7 common key's for every keyboard
Answers: 1
question
Computers and Technology, 23.06.2019 09:30
You wanted to look up information about alzheimer's, but you were unsure if it was spelled "alsheimer's" or "alzheimer's." which advanced search strategy would be useful? a) a boolean search b) using a wild card in your search c) trying different search engines d) doing a search for "alsheimer's not alzheimer's" asap. ill give brainlist.
Answers: 1
question
Computers and Technology, 23.06.2019 18:00
Ramona enjoys her job because she is able to kids in an after school program. the work value ramona feels strongest about is a. leadership b. risk c. independence d. work with people select the best answer from the choices provided a b c d
Answers: 1
You know the right answer?
Code example 5-1 import java. util. Scanner; import java. text. NumberFormat; public class WeightCon...
Questions
question
Mathematics, 25.01.2021 05:10
question
Mathematics, 25.01.2021 05:10
question
Biology, 25.01.2021 05:10
question
Mathematics, 25.01.2021 05:10
Questions on the website: 13722361