473,385 Members | 1,753 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Scanner input question

122 100+
have an scanner which prompts the user to
type some data into it.
for example
Lets say I have four strings.
String id
string name // this includes first and last name
string address //this includes the full address.
string price...

When the first scanner prompts the user they type in
DW123 and hits return
the next scanner prompts the user to type i the name
James Brown. and hits return.
when this happens I will get the next scanner running together
example
enter your address==>,enter the price==>

yet if I were to enter the name as JamesBrown it will work.

is there away around this.
any help would be greats

Sandy
May 17 '07 #1
3 1454
JosAH
11,448 Expert 8TB
have an scanner which prompts the user to
type some data into it.
for example
Lets say I have four strings.
String id
string name // this includes first and last name
string address //this includes the full address.
string price...

When the first scanner prompts the user they type in
DW123 and hits return
the next scanner prompts the user to type i the name
James Brown. and hits return.
when this happens I will get the next scanner running together
example
enter your address==>,enter the price==>

yet if I were to enter the name as JamesBrown it will work.

is there away around this.
any help would be greats

Sandy
When you do a Scanner.next() for reading a name and type "James Brown",
the Scanner reads a String which is "James" and stops reading. For the
address the Scanner will read "Brown" (it hasn't been read yet) and the
Scanner continues reading the price.

Better use Scanner.nextLine() for the name and full address if they contain
spaces. Correctly scanning human generated input is always difficult.

kind regards,

Jos
May 17 '07 #2
nomad
664 Expert 512MB
When you do a Scanner.next() for reading a name and type "James Brown",
the Scanner reads a String which is "James" and stops reading. For the
address the Scanner will read "Brown" (it hasn't been read yet) and the
Scanner continues reading the price.

Better use Scanner.nextLine() for the name and full address if they contain
spaces. Correctly scanning human generated input is always difficult.

kind regards,

Jos
Hey I can use this in the next article.
May 17 '07 #3
JosAH
11,448 Expert 8TB
Hey I can use this in the next article.
Everybody learns everyday ;-)

kind regards,

Jos
May 17 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: karimt | last post by:
I have a scanner connected to my server running Apache. I would like to have a script that allows me to get a pdf file directly from the scanner. Is this do-able?
1
by: Darren Coleman | last post by:
I need help with 2 keyboard/input questions 1. How do i caputre all keypress events for my application/form? 2. How do I determine which keyboard sent the keypress? What i'm doing is using a...
4
by: teddysnips | last post by:
I posted yesterday about a project I'm involved in to build a login application using a barcode scanner. I've solved most of the problems, but one remains. The client want to disable keyboard...
1
by: Louis Cypher | last post by:
I'm working on an application (OEM) using c# that uses input from a keyboard and a USB Barcode Scanner. I need to be able to identify keystrokes from the barcode scanner and remove them from the...
7
by: DemonWasp | last post by:
I've been having some trouble getting the Scanner class to operate the way I'd like. I'm doing some fairly basic file IO and I can't seem to get the class to load the last line/token any way I try....
4
by: Gerry19 | last post by:
Hi All, I'm trying to monitor data passed from a USB Barcode scanner but I can't find any decent code examples of what I need to do, including any references I need to include. I know I need to...
14
tolkienarda
by: tolkienarda | last post by:
hi all i read the scanner class documentation from sun's website and i thought i would have some fun trying to write a program that stores a line from the user to var input and then parses it on...
3
by: thename1000 | last post by:
Hi, I'm trying to create this output: Input team 1's name: Team 1 Input team 1's ranking: 90.4 etc.
2
by: CRGoose | last post by:
For my class i have to write a program that has a method to combine integer time input values into a single double value, return that to a method that sums the values, then return that to a main. ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.