Hi all,
Currently my code accepts x10 Floats into a Vector. How would I change it to terminate the loop and output all stored values when a negative number is entered?
import java.util.*;
public class acceptFloats
{
public static void main(String args[])
{
Vector<Float> vec = new Vector<Float>();
Scanner scanner = new Scanner(System.in);
System.out.println("Please insert a float: ");
for (int i = 0; i <10; i++)
{
Float temp = scanner.nextFloat();
vec.add(temp);
}
System.out.println(vec.toString());
}
}
(I know I suck at coding, I am new to it and still learning, so please no messages telling me how bad I am!).
Much appreciate the Help.