Answer:
class Main {
static void sequence(int n, int end, int step) {
for(;step>0 ? n<=end : n>=end; n += step) {
System.out.printf("%d",n);
if (n != end) System.out.printf(", ");
}
System.out.println();
}
public static void main(String[] args) {
sequence(2, 15, 1);
sequence(-10, 10, 1);
sequence(100, 90, -1);
sequence(40, 22, -3);
}
}
Step-by-step explanation:
Here is my solution again after being removed previously.