Results 1 to 7 of 7
Thread: Reading random order
- 05-11-2010, 02:10 AM #1
Member
- Join Date
- May 2010
- Posts
- 3
- Rep Power
- 0
Reading random order
Please help. I need to write a program that reads name, address and salary in random order from the keyboard. I am suppose to use exception handling techniques. I was going to read the entire line as a string, then search for "," as a delimiter. If I do this, I do not believe I need exception handling. This must not be the best way to do this. How would you do it?
- 05-11-2010, 02:18 AM #2
Senior Member
- Join Date
- Mar 2010
- Posts
- 952
- Rep Power
- 11
Sorry, but that makes no sense to me at all. The keyboard is by definition a sequential input stream. How can you read it in random order?
-Gary-
- 05-11-2010, 11:24 AM #3
Senior Member
- Join Date
- Feb 2010
- Location
- Ljubljana, Slovenia
- Posts
- 470
- Rep Power
- 12
I think he means the input can come in as name, address, salary; or salary,name,address etc.
Ever seen a dog chase its tail? Now that's an infinite loop.
- 05-11-2010, 02:22 PM #4
Member
- Join Date
- May 2010
- Posts
- 3
- Rep Power
- 0
m00nchile is correct. The variables can be entered in random order. Any ideas how to do this?
- 05-11-2010, 08:42 PM #5
Senior Member
- Join Date
- Feb 2010
- Location
- Ljubljana, Slovenia
- Posts
- 470
- Rep Power
- 12
Finding the salary wouldn't be a problem, as you can try parsing it as a Integer, when you don't get an exception, that's your value. Differentiating between the name and adress could be a bit trickier, as they are both Strings, maybe go through both string and see which one has only letters (name), and which one has digits in it as well (adress).
Ever seen a dog chase its tail? Now that's an infinite loop.
- 05-13-2010, 11:22 PM #6
Member
- Join Date
- May 2010
- Posts
- 3
- Rep Power
- 0
Thanks. That what I did. I did not know if there was a better way.
- 05-13-2010, 11:24 PM #7
Senior Member
- Join Date
- Feb 2010
- Location
- Ljubljana, Slovenia
- Posts
- 470
- Rep Power
- 12
Similar Threads
-
Math.random in array and reverse order
By eugenechia in forum New To JavaReplies: 4Last Post: 02-17-2010, 04:33 AM -
how i use the random class to random the cards i have
By yanipao in forum New To JavaReplies: 14Last Post: 10-19-2009, 11:57 AM -
problem with reading excel sheet data reading using poi libraries
By sandeepsai17 in forum New To JavaReplies: 5Last Post: 08-21-2009, 12:03 PM -
How do I generate random numbers in a certain range using the random class?
By frasifrasi in forum New To JavaReplies: 8Last Post: 04-19-2009, 06:50 PM -
random numbers without random class`
By carlos123 in forum New To JavaReplies: 4Last Post: 01-17-2008, 11:44 PM
Bookmarks