Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions