I am trying to obtain two integers as input, and then use these to output another list of integers, using the input as arguments in a loop.
In my code, if I enter low as 1, and high as 10 I expect my output should be the integers 1 through 10. However my code prints the value 1 ten times. I have tried different loops with no luck. Can someone please point out why my output is not as expected?
import java.util.Scanner;
public class test1 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Enter the low number: ");
int low = input.nextInt();
System.out.print("Enter the high number: ");
int high = input.nextInt();
//int num1 = low
//int num2 = high
System.out.println("Decimal");
for(int i = low ; low <= high; low++)
System.out.println(i);
}
}