This site requires JavaScript, please enable it in your browser!
Greenfoot back
ms20492
ms20492 wrote ...

2012/8/10

Terminal window

ms20492 ms20492

2012/8/10

#
Hello. New to Greenfoot....so pardon my newness. I'm consider using Greenfoot to use in my intro class. I can't seem to get Greenfoot's terminal window to accept input for some starting Java examples that are in our text using things like Scanner. Does anyone know if Greenfoot will work for this?
danpost danpost

2012/8/10

#
Greenfoot should work for this. What code are you trying to use? what do you want it to do? what is it doing? what class is the code in (and what are its super-classes)? Are you getting error messages? and if so, what exactly do they say? Answers to questions like these should be supplied to help resolve any issues easily (and quickly).
ms20492 ms20492

2012/8/10

#
sure...and thank you....this is super simple but I can't get it to respond like BlueJ.. import java.util.Scanner; public class Average { public static void main(String args) { int val1, val2, val3; double average; Scanner scan = new Scanner(System.in); // get three values from user System.out.println("Please enter three integers and " + "I will compute their average"); val1 = scan.nextInt(); val2 = scan.nextInt(); val3 = scan.nextInt(); //compute the average average = (double)(val1 + val2 + val3)/3; //print the average System.out.println ("The average is " + average); } }
danpost danpost

2012/8/10

#
I do not think I can be of much help on this matter. But these are my thoughts. First off, I believe that Greenfoot has a slightly different format than BlueJ; though, Greenfoot does use BlueJ. The line 'public static void main(String args)' would be used in BlueJ, but I do not think in Greenfoot. Secondly, but again, I cannot say for sure, the host environment (Greenfoot) may possibly have re-assigned the standard input device and therefore keystrokes are not captured without the use of Greenfoot's key checking methods. I tried coding it appropriately for use within Greenfoot, but after the initial message to enter three integers, it seems to freeze waiting for the input; though, I tried multiple delimeters ('enter', ';' 'space', etc.) between the integers. I did ask for information on what 'System.in' was and got 'BJInputStream...', but could not determine if that was the keyboard directly.
ms20492 ms20492

2012/8/13

#
Hmmm...thanks for trying. I'm guessing that JOptionPane input would work fine. Perhaps I'll just use BlueJ for the early system.In input stuff. I think main should be fine...that should be similar between platforms? I've not gone through the tutorials yet, so there might be more to Greenfoot than I understand. Thank you!
You need to login to post a reply.