If the user enters 118 at the console prompt, what is the third line of the resulting console display?

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 == false)
{
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 == false)
{
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;
}
}



If the user enters 118 at the console prompt, what is the third line of the resulting console display?


a. 53 kgs
b. 54 kgs
c. 53.64 kgs
d. 53.6363 kgs


Answer: 53.64 kgs


Learn More :