I'm new to Java and a "jung" boy from Germany. So sorry for my bad english.
Ok, I've got two Problems:
I save the Informations from my Program to a txt-File.
This saves the float-value (getPrice()) with a dot. For example 14.5
When I load the File I use this Code, same like getting the user input:
This want the float with a comma. For example 14,5.
I think Scanner uses the language configuration of the OS. PrintWriter uses english. How can I solve this problem?
My 2nd Problem is:
The user can make an Input and I want to handle wrong inputs. The actual code:
Of course there are Exceptions, for example at Line 07. The user writes characters... I can catch them, but I want to display the Error, and the user will get a 2nd chance to make his input. So I think I need a loop, but how can I write this?
For further informations you can take a look at the ProjectWiki. See my signature. There is a Mercurial repository and the last stable version of the program.
1) check out Scanner.useLocale to change the locale to Locale.US.
2) when writing use a NumberFormat to write the float, or use PrintWriter.printf when writing:
Personally, I would probably use a combination of both so you always know that, no matter the system, the output matches the input. And I also wouldn't use Locale.getDefault() then but a specific one like Locale.US or Locale.GERMAN.