Answer to Question #250988 in Java | JSP | JSF for mohd

Question #250988

Given an array A of N integers and two integers X and Y, find the number of integers in the array that are both less than or equal to X and divisible by Y.


1
Expert's answer
2021-10-13T16:58:29-0400
import java.util.Scanner;


public class App {


	public static void main(String[] args) {
		Scanner keyBoard = new Scanner(System.in);
		int t = keyBoard.nextInt();
		while (t > 0) {
			int n = keyBoard.nextInt();
			int x = keyBoard.nextInt();
			int y = keyBoard.nextInt();
			int a[] = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = keyBoard.nextInt();
			}
			int count = 0;
			for (int i = 0; i < n; i++) {
				if (a[i] <= x && a[i] % y == 0) {
					count++;
				}
			}
			System.out.println(count);
			t--;
		}
		keyBoard.close();
	}
}

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

SAKSHI
08.04.22, 08:44

Thank you it's worked.

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS