+ 3
Does anyone know how to run a java code automatically input using a Scanner??
Enter a number then get the results then allows you to enter a number again...
4 ответов
+ 3
Yes.. But I want to keep entering numbers without running it over and over...
+ 3
Scanner scan = new Scanner(System.in);
boolean stop = false;
while(!stop) {
//write your program here ..
System.out.println("Would you like to start again? (yes or no)");
String s = scan.nextLine();
if(s.equals("no")) {
stop = true;
}
}
+ 1
Are you referring to a mathematical parser where if you input something like "5+5/2", it'd output the answer?
+ 1
Check out my python parser. It is pretty much what you're describing except it's python instead of Java and it doesn't loop in that kind of fashion. Simply look over it and get an idea of what you need to do (iteration).