trying to use the io format to write a code that allows a user punch in 8 nos b/w 0 & 9 like in a pin code So far I've here is were I am
/* this is my first attempt at coding using throws java io trying to see if i could mimic reload a recharge voucher on to a cellphone. */
class Pincode { public static void main (String args []) throws java.io.IOException int codename // Hope I'm making sense,if not could someone correct me & put me on course thanks
Herb Schildt
Author
Ranch Hand
Joined: Oct 01, 2003
Posts: 239
posted
0
Chinedu: Here are a couple of points to help you get started. You can read a string from the keyboard using the following sequence
To convert the string into an integer, you can use this code:
Notice that you have to catch and handle NumberFormatException, which is thrown if the string being converted into an integer does not contain a valid integer value. One other point, although it is common in example programs to simply throw IOException out of main(), as you code does, you could also handle it inside main() by using a try/catch block similar to that required by Integer.parseInt().
If you are still having problems, let us know.
For my latest books on Java, including my Java Programming Cookbook, see HerbSchildt.com