How to ask for several integers from the program user?
I need to write a program in which you ask the user to input a bunch of integers (no set amount, as many as they want) in one line and then the line adds up all the integers that are positive and sets the value of that line equal to the sum.
So, I was wondering if I need to use a command that specifically sets a variable value to a list, or stack? because we haven't really learned about arrays yet?.
pasted the assignment:
(10 marks) A set of data is to be read and manipulated. You can read the data from standard input (i.e., from a user typing in a console window, or from a file using input redirection) or from JOptionPane dialog boxes. The number of lines is unknown. Each line of data contains
a line number, like 1., 2., 3., etc.
an integer n,
followed by n data values which are integers.
Write a complete Java program, consisting of only a class and a main method to read this data and print for each line
the line number followed by the product of the positive data values if there are any,
otherwise the line number followed by zero.
For example, if the input data is
1. 4 5 -3 2 7
2. 5 1 -3 5 6 -80
4. 1 -7
5. 2 6 -6
then your program would print