Respuesta :
import java.util.Scanner;
public class JavaApplication57 {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("Enter two numbers:");
int num1 = scan.nextInt();
int num2 = scan.nextInt();
while (num1 <= num2){
if (num1 %2 == 0){
System.out.print(num1+" ");
}
num1+=1;
}
}
}
I hope this helps!
The program is an illustration of loops.
Loops are used to carry out repetition operations; examples are the for-loop and the while-loop.
The program in Java, where comments are used to explain each line is as follows:
import java.util.*;
public class Main{
public static void main(String[] args) {
//This creates a Scanner object
Scanner input = new Scanner(System.in);
//This prompts the user for inputs
System.out.println("Enter two numbers: ");
//This gets input for the first number
int a = input.nextInt();
//This gets input for the second
int b = input.nextInt();
//This iterates from the first number to the second
for(int i = a; i<=b;i++){
//The following if condition checks, if the current number is even
if(i%2 == 0){
//If yes, the number is printed
System.out.print(i+" ");
}
}
}
}
At the end of the program, all even numbers between the interval are printed.
See attachment for sample run
Read more about similar programs at:
https://brainly.com/question/19742578
