0
Write a program which takes array of numbers until user inputs 0 and adds them
A program which will ask user to enter numbers and to stop they will need to type 0 The problem i cant use scanner since I don't know when the quantity of numbers the user will input. Arraylist allows arrays to expand dynamically as user inputs but I have no clue how it works practically. Any small example will be appreciated
3 odpowiedzi
+ 3
kuku Debbarma The code is right. But it won't work on Sololearn. You have to use an IDE on your PC. (On sololearn you can not input the numbers step by step)
+ 1
It has been quite a long time since I last programmed in Java, but if I remember correctly, you can do something like this:
Scanner sc = new Scanner(System.in);
int input;
while(input != 0)
{
input = sc.nextInt();
}
+ 1
Thank you for your response I will give it a try at morning!