The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

Re: Switch

Sorry that's a good point didn't really specify what the problem was. The program reads the input but once it gets past that i can't get the program to start the lower operations. I'm using Dr.java this is the error

java.util.InputMismatchException
at java.util.Scanner.throwFor(Unknown Source)
at java.util.Scanner.next(Unknown Source)
at java.util.Scanner.nextInt(Unknown Source)
at java.util.Scanner.nextInt(Unknown Source)
at question4.main(question4.java:21)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknow n Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Un known Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at edu.rice.cs.drjava.model.compiler.JavacCompiler.ru nCommand(JavacCompiler.java:272)

Re: Switch

java.util.InputMismatchException
at java.util.Scanner.throwFor(Unknown Source)
at java.util.Scanner.next(Unknown Source)
at java.util.Scanner.nextInt(Unknown Source)
at java.util.Scanner.nextInt(Unknown Source)
at question4.main(question4.java:21)

The call to nextInt() at line 21 is trying to read an int value from the keyboard but the user is entering something that is not a numeric value. Use the next() or nextLine() method if you want to read a String not a number.

Re: Switch

Thank you, this is kind of making me feel like i may not be able to go about it in this way. It makes my option not work in the string anymore. Says that i can not make option a variable, would i have to convert a Int to a String which i have read is not a simple solution, or is there another way?