I'm working on a simple mortgage calculator right now cause I'm new to coding and not very good at it I'm trying to get ask the user how big the loan is so I'm trying to user Number.format for currency so I can set it up as a currency
What I'm trying right now looks like this
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()));`
This is returning
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)`
What I excepted is that it would take the users input which starts as a string and parse it to an integer then as the user was putting in the input (Ex: 1000000) it would format it to look like a currency (If there are any problems with how im asking sorry this is my first time asking a question on stack overflow)