【发布时间】:2015-11-02 01:17:04
【问题描述】:
我在这里有一个循环读取双精度值,但对于程序我需要将它与字符 q 进行比较,如果用户输入 q,循环将结束。我不确定在这里做什么。
while (currencyValue != 'q')
{
System.out.printf("Formatted currency value: $%,.2f\n", currencyValue);
System.out.print("Enter a currency value or enter q to quit: ");
currencyValue = stdIn.nextDouble();
}
感谢您的帮助
【问题讨论】:
-
反转它:读取一个字符串,检查它是否为 q,如果不是,尝试将其解析为 double。