Unit 4: Lesson 2 - Coding Activity 1
Ask the user for two numbers. Print only the even numbers between them. You should also print the two numbers if they are even.

Starter code:
import java.util.Scanner;

public class U4_L2_Activity_One{
public static void main(String[] args){

Scanner scan = new
Scanner(System.in);
System.out.println("Enter two numbers:");
int num1 = scan.nextlnt();
int num2 = scan.nextlnt();
while (num1 <= num2){
if (num1 %2==0){
system.out.print(num1="");
}
num+=1;
}
}
}

Respuesta :

The program illustrates the use of loops.

Loops are used to perform repetitive and iterative operations.

Aside few errors that can easily be corrected, the starter code you added to the question is not totally incorrect.

So, the corrected code is:

import java.util.Scanner;

public class U4_L2_Activity_One{

   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;

       }

}

}

The above program is the same as the starter code, you included.

I only made corrections to lines 6, 7, 9, 10 and 15

Read more about similar programs at:

https://brainly.com/question/19270993

ACCESS MORE
EDU ACCESS