Write a program whose input is two integers, and whose output is the first integer and subsequent increments of 5 as long as the value is less than or equal to the second integer.
Ex: If the input is:
-15 10
the output is:
-15 -10 -5 0 5 10
Ex: If the second integer is less than the first as in:
20 5
the output is:
Second integer can't be less than the first.
For coding simplicity, output a space after every integer, including the last.
import java.util.Scanner;
public class LabProgram {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
int start = scnr.nextInt();
int end = scnr.nextInt();
if(start end){
System.out.println("Second integer can't be less than the first.");
}
else{
while(start=end){
System.out.print(start + " ");
start+=5;
}
System.out.println();
}
}
}
tutorial,increment and decrement operators,increment,the best tutorial on increment operator,uses of increment operator,java tutorial,java 8 tutorial with examples,c programming tutorial,increment and decrement c++,java tutorial for beginners,increment operator in c,range of integer data type,increment operator,increment operators,easy method for increment operator,logic behind increment operator,increment operator functions,questions on increment operator