I made a calculator and now improving it so that it reads one line of code and turns it into three variables a: first number, b: second number, and function: what it does example: 10 * 10
. This is my code:
System.out.println("problem: ");
problem = user_input.next();
StringTokenizer token = new StringTokenizer(problem," ");
a = Integer.parseInt(token.nextToken());
String Menu = (token.nextToken());
b = Integer.parseInt(token.nextToken());
It doesn't understand nextToken at all, it says at Exception in thread "main" java.util.NoSuchElementException
at java.util.StringTokenizer.nextToken(Unknown Source)
at mycalc.main(mycalc.java:20)
,
also I asked a friend that actually showed me how this works and he was confused too. Please help me any possible way you can!