Answer:
public static void main (String [] args) {
public static void main (String [] args) {
int count = 0;
int[] arr = new int[args.length];
if(args.length >=2) {
for(int i=0; i<args.length; i++) {
arr[i] = Integer.parseInt(args[i]);
if(arr[i] % 10 == 0)
count++;
}
}
else
throw new IllegalArgumentException("Missing arguments!");
System.out.println("There are " + count + " numbers that are divisible by 10");
}
Explanation:
- Create a variable <em>count</em> to hold the count of the numbers divisible by 10
- Initialize an integer array to hold the inputs
- Check the number of arguments that are passed as a parameter. If it is greater than 2, parse the numbers into the <em>arr.</em> Then check the numbers that are divisible by 10, if number satisfies the condition, increment the <em>count </em>by 1.<em> </em>If the length of arguments passed is less than 2, throw an exception
Then:
Print the <em>count</em>