so I am fairly new to Java, and most of my previous knowledge is with Python and C++ so I am not really sure how to store data that is inputted so it can be compared. So essentially I am looking to have the user input a bunch of integer values - whatever number they would like. However, when they keep entering these values what will happen is when it is descending (if it descends 3 times in a row) it will break the loop and the program will end. I am not sure how to make the inputted data be stored so it can be compared to the previous entry, or if there is a way to do this without using lists (as I would do in python).
So far what I have is very basic and I need to figure out how to make the if statement in the while loop to be able to compare the previous inputs.
public static void main (String[] args)
{
Scanner keyboard = new Scanner(System.in);
System.out.println("Enter your number: ");
int n = keyboard.nextInt();
while (true) {
if (n > 0) {
System.out.println("Enter your new number: ")
int n = keyboard.nextInt();
}
}
}
Sorry if this isn't a lot to go on, but I really do not know where to start in terms of comparing the values that are entered in - only really know how to get them to be entered in.