I want to capture user input ( for teaching purposes - not an actual application). I don't want to use the dialgoue scenario - I just want to KIS and use Java principles.
I have:
The Greenfoot terminal opens, prompting for input, but that's all I can get it to do.
Your help would be appreciated.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | import java.util.Scanner; public class Input extends Actor { private static Scanner scan; public void act() { // Add your action code here. input(); } public void input(){ int a; float b; String s; Scanner in = new Scanner(System.in); System.out.println( "Enter a string" ); s = in.nextLine(); System.out.println( "You entered string " +s); } } |