In: Computer Science
Write in java please
Instructions
Code Structure
main(){
N = take input from user;
arr = create a N-size array.
populate the array with user inputs.
call the checkArray() method and send arr.
}
checkArray(){
for each array member of arr, check if it is a multiple of 15 and 20 or not.
print the results.
}
Sample Output
What is the size of the array? 3
Give me 3 numbers. 10 20 15
10: !MULT15: !MULT20
20: !MULT15: MULT20
15: MULT15: !MULT20
import java.util.Scanner;
import java.util.Arrays;
public class multipliers
{
   public static void checkArray(int [] arr)
   {
       for(int i=0; i<arr.length;
i++)
       {
           String
str1;
           String
str2;
           if(arr[i]%15 ==
0)
           {
          
    str1="MULT15: ";
           }
           else
           {
          
    str1="!MULT15: ";
           }
           if(arr[i]%20 ==
0)
           {
          
    str2="MULT20";
           }
           else
           {
          
    str2="!MULT20";
           }
          
System.out.println(+arr[i] +": " +str1 +str2);
       }
   }
   public static void main(String args[])
   {
   int N = 0;
   int[] arr;
   Scanner scan = new Scanner(System.in);
   System.out.print("What is the size of the array?
");
   if (scan.hasNextInt())
   {
       N = scan.nextInt();
       scan.nextLine();
}
   arr = new int[N];
   System.out.print("Give me " +N +" numbers. ");
   String[] strNums = null;
if (scan.hasNextLine())
   {
       strNums = scan.nextLine().split("
");
}
if (strNums != null)
   {
for (int i = 0; i < N; i++)
       {
try
           {
arr[i] = Integer.parseInt(strNums[i]);
}
           catch (Exception
e)
           {
System.out.println("Invalid input");
break;
}
}
}
       checkArray(arr);
   }
}