Answer to Question #315758 in Java | JSP | JSF for jhem

Question #315758

I'm really fond of even numbers, you know? That's why I'll be letting you make another even number problem yet again. This time, you need to print from a range of two inputted numbers, n1 and n2 (inclusive), all the even numbers from n2 down to n1, in descending order.





1
Expert's answer
2022-03-22T03:58:30-0400
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        System.out.print("Enter n1 number: ");
        int n1 = in.nextInt();

        System.out.print("Enter n2 number: ");
        int n2 = in.nextInt();

        for(int i = n2; i > 0; i--){
            if(i%2 == 0){
                System.out.print(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