Answer to Question #249734 in Java | JSP | JSF for Nguu

Question #249734

Using a for loop create a program that will prompts the user for two numbers and then print out a list of even number in between the two given numbers(inclusive), starting from the small number to the big number


1
Expert's answer
2021-10-12T00:37:11-0400
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) {
		Scanner input=new Scanner(System.in);
		System.out.println("Enter the two numbers smaller and larger: ");
		int N=input.nextInt();
		int X= input.nextInt();
		for(int i=N;i<=X;i++){
		    if(i%2==0){
		        System.out.println(i+" ");
		    }
		}
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS