This is where your code is breaking.
highest=lowest;
lowest=n;
Now about initializing these variables.
How I, personally would start this program would be initializing both the lowest and highest with n.
So you don't have to worry any bounds.
System.out.println("Enter any positive or negative number");
int n = in.nextInt();
int highest = n;
int lowest = n;
for(int i = 0; i < 9; i++){
System.out.println("Enter any positive or negative number");
n = in.nextInt();
if(n > highest){
highest = n;
}else if (n < lowest){
lowest=n;
}
}
System.out.println(highest);
System.out.println(lowest);
This asks the user to input 10 different digits. then prints out the highest and lowest values.
else if (n < lowest)
this could also be a else if
because if n
is the highest value it cant be also the lowest value because of my initialization at the start.