subject
Computers and Technology, 05.05.2020 22:16 dajahp

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

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 17:00
What does the faves button do? a. users mark a web page as a favorite b. leads other readers to favor a specific page c. readers sort and align their favicons, or favorite icons d. leads users to a message board where they can post questions
Answers: 1
question
Computers and Technology, 24.06.2019 02:00
Write an expression that will cause the following code to print "equal" if the value of sensorreading is "close enough" to targetvalue. otherwise, print "not equal". ex: if targetvalue is 0.3333 and sensorreading is (1.0/3.0), output is:
Answers: 1
question
Computers and Technology, 24.06.2019 15:00
Who introduced the concept of combining artificial and natural light in the studio
Answers: 1
question
Computers and Technology, 24.06.2019 16:30
You may see the term faq on websites which stands for frequently asked questions this is an example of which type of mnemonic? a) poem b) acronym c) acrostic d) abbreviation ken has dipped many dark chocolate marshmallows (which you remember the metric system distance units in decreasing order: kilometers, hectometer, decameter, centimeter, millimeter) is an example of which type of mnemonic? a) poem b) acronym c) acrostic d) abbreviation !
Answers: 1
You know the right answer?
Project 4: Strictly Identical arrays

Problem Description:

Two arrays are str...
Questions
question
Mathematics, 19.04.2021 23:50
question
Mathematics, 19.04.2021 23:50
question
Mathematics, 19.04.2021 23:50
Questions on the website: 13722363