I can think of those scenarios in my project. However, the exercise was limited to what it requested from me. I think this is the final solution to the exercise. However, time is against me to work...
Type: Posts; User: belinyom
I can think of those scenarios in my project. However, the exercise was limited to what it requested from me. I think this is the final solution to the exercise. However, time is against me to work...
What do you mean by the code does not check the user's input for validity?
You have a point about assigning an int to a variable only, I am used to that. I try to understand my coding more often...
Thank you once again
import java.util.ArrayList;
import java.util.Scanner;
public class OnlyTheseNumbers {
Quite interesting, even though I struggled with a simple exercise, I did learn a lot.
I thank you for your insight and understanding.
I have finally solved the problem, would you like me to...
I have tried it numerous times. If a question is asked to the user, the user is able to respond to that question. But in Java, a variable must be declared before a question is asked. If there is a...
I do not think that this is possible because I still need to declare a new scanner input variable for 2 values and the declaration has to be done before printing it out. How can I print something...
the output should look exactly like this according to the exercise:
10
20
30
40
50
-1
From where? 0
import java.util.ArrayList;
import java.util.Scanner;
public class OnlyTheseNumbers
{
public static void main(String[] args)
{
Scanner inputReader = new...
that is really strange: https://imgbox.com/9Wi67jLg
I have added system.out.println(listOfNumbers) to show the set or collection of array, the loop still did not break. why is the IF condition not...
10
20
30
40
50
-1
0
From where? 0
2
To where? 2
Thank you for clarifying the concept, I have managed to pull the output as I wanted it to be. But, when I input any random numbers in an array list and try to input -1 to stop the loop, the while...
this turned out to be more confusing than I thought
Why can it return -1 and what is the point of that?
To clear my confusions,
.size gives the size of an array by totalling the amount of...
Thank you for clarifying that part, I did print out the content of that array list by simply adding system.out.println(listOfNumbers) which shows me the whole set of an array list, if i input 5...
I assume -1 was counted as the last index when I stopped the loop from running. How can I exclude -1 from inputNumber (input user in this case) and stop the while loop at the same time?
Exception...
Hello there, I have been stuck with this exercise for quite some time and I really do not know how to meet its requirements.
I am trying to input random numbers [10, 20, 30, 40 and 50] to an array...