То, что я пробую сейчас, выглядит так, как это < /p>
< /p>
.
Код: Выделить всё
NumberFormat percent = NumberFormat.getPercentInstance();
NumberFormat currency = NumberFormat.getCurrencyInstance();
Scanner scanner = new Scanner(System.in);
System.out.print("How big is your loan: ");
int loanSize = Integer.parseInt(currency.format(scanner.nextInt()));`
< /code>
Это возвращает < /p>
Exception in thread "main" java.lang.NumberFormatException: For input string: "$1,000,000.00"
at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:67)
at java.base/java.lang.Integer.parseInt(Integer.java:588)
at java.base/java.lang.Integer.parseInt(Integer.java:685)
at Main.main(Main.java:23)`
Подробнее здесь: https://stackoverflow.com/questions/795 ... -exception