Code: Select all
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>
Dies kehrt < /p>
zurückException 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)`