Beginner Java coder here, I have a simple Scanner application that takes user input. I want to put an if statement to prevent the user from putting negative values into the scanner, or at least get an error message when they do so.
I have tried to put an if statement that if the number > 0 then the code executes, else displays an error message. This seems to work when testing for x, but not for x OR y.
if (x >= 0 || y >= 0){ System.out.println("Sum of x+y = " + z); if (x == y) { System.out.println("x and y are equal"); } else { System.out.println("x and y are not equal"); System.out.println("Counting from 0 to " + x); for (int i = 0; i <= x; i++) { System.out.print(i + " "); }