I have three different input values that must pass in order
Solution
import java.util.*;
public class Lab5b
{
public static void main(String ss[])
{
int no;
//Scanner class Object created
Scanner sc = new Scanner(System.in);
System.out.println(\"Enter number of elements: \");
no = sc.nextInt();
double [] cellBills1 = new double[no];
System.out.println(\"Enter number of elements: \");
no = sc.nextInt();
double [] cellBills2 = new double[no];
boolean isEqual = true;
System.out.println(\"Enter the value for the cellBills1\");
for(int c = 0; c < cellBills1.length; c++)
cellBills1[c] = sc.nextDouble();
System.out.println(\"Enter the value for the cellBills2\");
for(int c = 0; c < cellBills2.length; c++)
cellBills2[c] = sc.nextDouble();
//Compares the length
if(cellBills1.length != cellBills2.length)
isEqual = false;
else
{
for(int c = 0; c < no; c++)
{
//Compare the array contents
if(Math.abs(cellBills1[c] - cellBills2[c]) > 0.001)
isEqual = false;
}
}
if(isEqual)
System.out.println(\"CellBill1 and CellBill2 are equal\");
else
System.out.println(\"CellBill1 and CellBill2 are not equal\");
}
}
Output 1 :
Enter number of elements:
3
Enter number of elements:
3
Enter the value for the cellBills1
10.23
11.33
2.3
Enter the value for the cellBills2
10.23
11.33
2.3
CellBill1 and CellBill2 are equal
Enter number of elements:
3
Enter number of elements:
3
Enter the value for the cellBills1
10.23
23.0
22.3
Enter the value for the cellBills2
10.3
23.0
22.3
CellBill1 and CellBill2 are not equal
Output 3:
Enter number of elements:
3
Enter number of elements:
4
Enter the value for the cellBills1
10.2
11.2
12.2
Enter the value for the cellBills2
10.2
11.2
12.2
13.2
CellBill1 and CellBill2 are not equal

