I want to make a loop where the user inputs multiple values and when they want to stop input their values they input -1. I know it has to use a sentinel but I don't know how.
Scanner myInput = new Scanner(System.in);
int total = 0;
int count = 0;
while(values >= 0)
{
int values;
total += values;
count ++;
System.out.println("Please input your value, type - 1 to stop entering values.");
values = myInput.nextInt();
}
System.out.println ("The sum of all your values is " + total);