Well... haven't give your calculations any thought (guess you know what you are doing...), but first you must increse your variable "i" (like i++) somewhere within your while -loop, or your will never get out of that scoop. Also, perhaps you must "flush();" your ScreenWriter (?). Don't know if it works like the "OutputSreamWriter" -class ?, which must bee flushed to print anything (default). Is "ScreenWriter" part of jdk 1.4 ?
Regards stefan -----Ursprungligt meddelande----- Fr�n: Tim Nicholson [mailto:[EMAIL PROTECTED]] Skickat: den 22 september 2002 15:52 Till: JDJList �mne: [jdjlist] having a problem that I can't understand.... Hi, can somebody please help me ? I am trying to run the following code :- ---------------------------------------------------------------------------- ------------- import TerminalIO.*; public class Liebniz { KeyboardReader reader = new KeyboardReader(); ScreenWriter writer = new ScreenWriter(); int i; int x; int numiter; double valuesofar; //================================================================ public void run() { numiter = reader.readInt("Enter number iterations for Pi value: "); i = 1; x = 1; valuesofar = 0; while (i <= numiter) { if(i % 2 == 0){ valuesofar = valuesofar - (1 / x); } else { valuesofar = valuesofar + (1 / x); } x = x + 2; } writer.println("The value so far is: " + valuesofar); } //================================================================= public static void main(String [] args) { Liebniz tpo = new Liebniz(); tpo.run(); } } ---------------------------------------------------------------------------- --------------------- And when I execute it, it succeeds in asking me to enter a number of iterations but then after I have entered in an integer and push enter, nothing more happens. In other words it only gets as far as the cursor going onto the next line. But nothing more happens. So it doesnt display any output to my input. The cursor just goes to the next line and stops and I have to push the X button in the top right hand corner of the window to get it to close. What usually happens is that it runs its output and then says "push any key to continue " but when I try this program it doesnt do any of that. It just sits on the next line after I have entered my input and it doesnt display anything more. Can someone please help me with this ? I get no compile errors by the way with this. The program is also attached as a .java file if that makes things any easier ? To change your JDJList options, please visit: http://www.sys-con.com/java/list.cfm
