Ask your own question, for FREE!
Computer Science 8 Online
OpenStudy (anonymous):

I need help creating a program that will take user input (using scanner) and place it in a double array. I keep getting runtime errors!

OpenStudy (anonymous):

this is what i have so far: import java.util.Scanner; public class Marks{ public static void main(String[]args){ final int VALUES_LENGTH = 25; double[] values = new double[VALUES_LENGTH]; int valueCount = 0; Scanner in = new Scanner(System.in); System.out.println("Please enter some values"); while(in.hasNextDouble()) { if(valueCount< values.length) values[valueCount] = in.nextDouble(); valueCount ++; } for(int i = 0; i<valueCount; i++) System.out.println(values[i]); System.exit(0); }

OpenStudy (rsmith6559):

The only thing that I don't like about your code is using the name "in" for your Scanner. I'm concerned that in is a reserved word, and if nothing else, it is used as part of System.in. Without knowing that actual errors, this is kind of shooting in the dark.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!