I have been trying to figure out what's wrong with this answer to the question. Really need help! Any help is appreciated! Thanks
Question
- you can enter two ints(a and b), and
- the program will print from number a to number b if
a<b. - If
a>b, the program will print from b to a. If
b is the same as a, the program will ask the user to enter another number b until it is not equal to a.Scanner sc = new Scanner(System.in); System.out.println("Enter a: "); int a = sc.nextInt(); System.out.println("Enter b: "); int b = sc.nextInt(); if(a > b) { for(int i = b; b >= a; b--) { System.out.println(b); } } else if (a < b) { for(int i = a; a <= b; a++) { System.out.println(i); } } else { System.out.println("Enter another number b: "); int numberb = sc.nextInt(); }}