• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Currency Problem + General Advice

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi again all,
I was just wondering how to insert the Pound Sterling Symbol "�" into a Java program running in the command prompt.
I was also wondering if one of you could maybe check the code below and make sure it is ok and maybe give me some pointers to tidy it up if there are any. Thanks in advance guys, your all a really great help!


Thanks in advance!
Regards,
Emile
 
Ranch Hand
Posts: 815
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As for command prompt, I think you're out of luck. Were you to write your application in a GUI, you could simply use unicode characters. If I remember correctly, pounds sterling is '\u00A3' (I looked that up). Charts abound on the web, this one's my favorite:
Unicode Charts
 
Emile Ghazzawi
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi again,
Any tips you could give on the posted code? Or does it all look ok to you?
Regards,
Emile
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Overall it looks pretty good.
A few things:-
1) when you start the program the first time - if you do nothing except
select (6) quit, it errors when you open the program the next time. Test by renaming your current "stock.txt".
this can be fixed by changing
do
{
}while (input.ready());
to
while (input.ready())
{
}
but don't know if this will break something else
2) suggest your program which look like this

to this

this way your code can be called by another program
3) when displaying the results of a query eg current stock level, after the
code to display the results, add something like this
System.out.println("Press [ENTER] to continue");
String junk = input.readLine();
this way the result will be at the bottom of the screen, where it is
expected to be, instead of near the top, with the next option menu showing
at the bottom ie you currently have to search the screen for the result.
4) if you want to have a bit of fun, try to convert it from arrays of data
to a HashMap of objects - StockItem, with the stockCode being the key

I'm away for a couple of days, and if I get a chance I'll try to rewrite it
the way I've suggested, which is probably an easier way to show you the
difference.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's a bit of a re-write. It essentially does the same thing as your code.
I've added a couple of menu items and changed the saving of the data to
after each change.
The main difference is removing the limit of stock items.
 
There are 29 Knuts in one Sickle, and 17 Sickles make up a Galleon. 42 tiny ads in a knut:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic