Question
Enter your choice: 3 Enter customer ssn: 45455656667 Amount: 200 Exception in thread main java.lang.NumberFormatException: For input string: 200,00 kr at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2043) at sun.misc.FloatingDecimal.parseFloat(FloatingDecimal.java:122) at
Enter your choice: 3
Enter customer ssn: 45455656667
Amount: 200
Exception in thread \"main\" java.lang.NumberFormatException: For input string: \"200,00 kr\"
at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2043)
at sun.misc.FloatingDecimal.parseFloat(FloatingDecimal.java:122)
at java.lang.Float.parseFloat(Float.java:451)
at com.StefanAxelssonJava.SavingsAccount.(SavingsAccount.java:25)
at com.StefanAxelssonJava.Customer.createAccount(Customer.java:42)
at com.StefanAxelssonJava.Main.main(Main.java:86)
My switch/case block of code below:
case 3: {
System.out.print(\"Enter customer ssn: \");
ssn = sc.nextBigInteger().toString();
List customers = Bank.getCustomers();
for (Customer c : customers) {
if (Objects.equals(c.getSSN(), ssn)) {
System.out.print(\"Amount: \");
float amount = sc.nextFloat();
NumberFormat.getCurrencyInstance(new Locale(\"sv\", \"SE\")).format(amount);
if (amount != 0) {
c.createAccount(1.2f, amount);
System.out.println(\" Account added for customer with ssn: \" + ssn);
} else {
System.out.println(\" Amount must be over 0 \");
}
}
}
}
break
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started