Ask the user for the size of the cellBills1 array Enter numb
Solution
import java.util.*;
import java.lang.*;
import java.io.*;
class arrays
{
public static void main (String[] args)
{
Scanner scan = new Scanner(System.in);
int i;
System.out.println(\"Enter the size of cellBills1 Array\");
int numElements = scan.nextInt();
int[] cellBills1 = new int[numElements]; //input size of cellBills1
System.out.println(\"Enter the size of cellBills2 Array\");
numElements = scan.nextInt(); //input size of cellBills2
int[] cellBills2 = new int[numElements];
boolean isEqual = true;
System.out.println(\"Enter the elements of array cellBills1:\");
for(i=0;i<cellBills1.length;i++) //input values for array cellBills1
cellBills1[i] = scan.nextInt();
System.out.println(\"Enter the elements of array cellBills2:\");
for(i=0;i<cellBills2.length;i++)
cellBills2[i] = scan.nextInt(); //input values for array cellBills2
if(cellBills1.length != cellBills2.length) //compare size of arrays
isEqual = false;
else
{
for(i=0;i<numElements;i++)
{
if(cellBills1[i] != cellBills2[i]) //compare all elements of arrays
isEqual = false;
}
}
if(isEqual == true)
System.out.println(\"Arrays cellBills1 and cellBills2 are equal in length and values\");
else
System.out.println(\"Arrays cellBills1 and cellBills2 are not equal\");
}
}
output:

