+ 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...

25th Nov 2016, 10:09 PM
Marshall Moyo
Marshall Moyo - avatar
4 ответов
+ 3
Yes.. But I want to keep entering numbers without running it over and over...
25th Nov 2016, 11:00 PM
Marshall Moyo
Marshall Moyo - avatar
+ 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; } }
2nd Dec 2016, 11:37 AM
Mohammed Imad-Eddine BOUCENDA
Mohammed Imad-Eddine BOUCENDA - avatar
+ 1
Are you referring to a mathematical parser where if you input something like "5+5/2", it'd output the answer?
25th Nov 2016, 10:54 PM
Ben
Ben - avatar
+ 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).
25th Nov 2016, 11:03 PM
Ben
Ben - avatar