Write Java code which reads numbers from the keyboard until zero is entered. Only the positive numbers entered are to be added to a variable-sized collection.
This is what I have so far:
import java.lang.*;
import java.util.*;
import java.io.*;
import java.net.*;
public class Demo1App extends Object
{
public static void main(String[] argStrings) throws Exception
{
ArrayList myArrayList = new ArrayList();
Scanner input = new Scanner(System.in);
System.out.println ("NUMBERS:");
while (int input > 0)
{
myArrayList.add(input);
}
while (int input < 0)
{
System.out.println ("ENTER NUMBERS GREATER THAN 0!");
}
}
}
This code doesn't work, I'm not sure why but any help with it would be appreciated.