Write a program with class name strictlyidentical that


Project 4: Strictly Identical arrays

Problem Description:

Two arrays are strictly identical if their corresponding elements are equal. Write a program with class name StrictlyIdentical that prompts the user to enter two lists of integers of size 5 and displays whether the two are strictly identical.

Here are two sample runs:

Sample 1:

Enter 5 elements of list1: 23 55 31 2 10

Enter 5 elements of list2: 23 55 31 2 10

Two lists are strictly identical.

Sample 2:

Enter 5 elements of list1: 23 55 31 2 10

Enter 5 elements of list2: 23 55 3 2 10

Two lists are not strictly identical.

You need to define and utilize a user-defined function using the following method header:

public static boolean equals(int[] array1, int[] array2)

This method will return true if array1 and array2 are strictly identical otherwise it will return false. Note that it is incorrect to check the equality of two arrays using array1 == array2 because they are reference type variables. You need to use a for loop to check each element of array1 and array2. If any of the corresponding elements differ, these two lists are not strictly identical. If all of the corresponding elements are the same, these two lists are strictly identical.

You can use the following steps in your code:

Declare and create two arrays list1 and list2 of integer type and size 5.

Prompt the user to enter 5 elements of list1 and list2. Use for loop to read these entries and assign them to the elements of list1 and list2 respectively (for example, list1[i] = input.nextInt().)

Invoke the boolean method equals (that you defined) to pass the two arrays. If the return type is true then display that the lists are strictly identical. Otherwise, display that the two lists are not strictly identical.

What to deliver?

Your .java file including:

1. (Code: 5 points, Comments: 3 points)
Your code with other appropriate comments.

2. (2 points) Two sample run test the following lists:

(1) 1 2 3 4 5 and 1 2 3 4 5

(2) 1 2 3 4 5 and 5 4 3 2 1

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: Write a program with class name strictlyidentical that
Reference No:- TGS02902746

Expected delivery within 24 Hours