• 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
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown
Bartenders:

How do I use a (boolean?) token to reject user input?

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a program in which a user buys an item at a store. I have the user input the itemName, quantity, unitPrice, and whether it is taxable or not in a String which is tokenized into four parts, delimited by the "|" character.
Example: itemName|quantity|unitPrice|N
The N or n in the fourth token tells whether the purchase is taxable.
How can I use Java to reject the input and display an error message to the user if the fourth token is not input as a "n" or a "N"?
Any help is greatly appreciated!
 
Michael Fraczek
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is a sample of the code I have written so far:

[ November 30, 2002: Message edited by: Marilyn de Queiroz ]
 
Greenhorn
Posts: 15
IntelliJ IDE Chrome Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Perhaps you could use:
[QOUTE]

Tests if this string ends with the specified suffix.

of you could use:

if you're into regular expressions...
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic