1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Karolina [17]
3 years ago
5

Write a method called equals that takes in two string arrays and returns true if they are equal; that is, if both arrays have th

e same length and contain equivalent string values at each index.
Computers and Technology
1 answer:
Sonja [21]3 years ago
8 0

Answer:

public boolean equals( String [ ] a, String [ ] b ){

       if (a.length == b.length){

           for (int i = 0; i < a.length; i++){

               if ( ! a [ i ].equals( b [ i ] )) {

                   return false;

               }

           }

           return true;

       }

       return false;

   }

Explanation:

The above code has been written in Java.

// 1. Method header declaration

// Method name is <em>equals.</em>

<em>// </em>It takes in two arguments which are the two string arrays <em>a</em> and <em>b.</em>

// Since the method returns a true or false, the return type is boolean

public boolean equals( String [ ] a, String [ ] b ){

       

       // 2. Check if the two arrays are of same length

       if (a.length == b.length){       // Begin outer if statement

           

           // If they are equal in length,

           // write a for loop that cycles through the array.

           // The loop should go from zero(0) to one less than

           // the length of the array - any of the array.

           for (int i = 0; i < a.length; i++){

               // At each of the cycle, check if the string values at the index which

              // is i, of the two arrays are not equal.

               if ( ! a [ i ].equals( b [ i ] )) {

                 

                   // If they are not equal, exit the loop by returning false.

                   return false;

              }

          }

          // If for any reason, the for loop finishes execution and does not

          // return false, then the two arrays contain the same string values at

          // each index. Therefore return true.

           return true;

       }                // End of outer if statement

       // If none of the return statements above are executed, return false.

       return false;

   }      // End of method.

<em>Hope this helps!</em>

You might be interested in
14. In cell B14, create a formula without using a function that adds 1 to the value in cell B12 and then multiplies the result b
vagabundo [1.1K]

Answer:

The formula for the given problem is given below:

= (1+B$12)×B13

Explanation:

Immediately you do one, then you can autofill the formula to the mentioned range B15:B17 and then to C14 to H17

When been done correctly, this is how the formula will look in those cells if you do it correctly.

Check the file attached below to see it.

7 0
3 years ago
PLZ HELP 60 points!! Minor changes to objects which only take effect at render time are called:
slega [8]
It’s literally all b
5 0
3 years ago
1.6<br> What do you call the two parts of the lift that goes down a mine?
Likurg_2 [28]

Answer:

Sheave wheel and hoist cable

Explanation:

The sheave wheel is a pulley wheel that sits above the mine shaft. The hoist cable passes over the sheave wheel and then down the shaft of the mine. The sheave wheel reduces the sliding friction of the mine cable. The head frame is the structure that supports the sheave wheel.

7 0
3 years ago
47. Which of these examples demonstrates good netiquette?
Masteriza [31]

Answer:

typing it, on a video detailing how boring and poorly made it is

Explanation:

this is an example of good netiquette because they are criticizing the video game and what good netiquette is is making a comment relevant to the original message. the original message being the video game

3 0
3 years ago
See the lseek_example.c file. Modify the lseek_example.c, such that it reads from an input file (named "start.txt") and will pri
andre [41]

Answer:

See the lseek_example.c file. Modify the lseek_example.c, such that it reads from an input file (named "start.txt") and will print to an output file (named "end.txt") every (1+3*i)th character, starting from the 1st character in the input file. In other words, it will print the 1st character, then skip 2 characters and print the 4th one, then skip 2 characters and print the 7th one, and so on.

For instance, for input file:

ABCDEFGHIJKLM

It will output:

ADGJM

Iseek_example.c file contant:

// C program to read nth byte of a file and

// copy it to another file using lseek

#include

#include

#include

#include

void func(char arr[], int n)

{

// Open the file for READ only.

int f_read = open("start.txt", O_RDONLY);

// Open the file for WRITE and READ only.

int f_write = open("end.txt", O_WRONLY);

int count = 0;

while (read(f_read, arr, 1))

{

// to write the 1st byte of the input file in

// the output file

if (count < n)

{

// SEEK_CUR specifies that

// the offset provided is relative to the

// current file position

lseek (f_read, n, SEEK_CUR);

write (f_write, arr, 1);

count = n;

}

// After the nth byte (now taking the alternate

// nth byte)

else

{

count = (2*n);

lseek(f_read, count, SEEK_CUR);

write(f_write, arr, 1);

}

}

close(f_write);

close(f_read);

}

// Driver code

int main()

{

char arr[100];

int n;

n = 5;

// Calling for the function

func(arr, n);

return 0;

}

Explanation:

3 0
3 years ago
Other questions:
  • What does the int size = sizeof buffer / sizeof * buffer means ?
    7·1 answer
  • Review the given requirements using the checklist and discover possible problems with them. The following requirements are for a
    8·1 answer
  • You want to make it possible for your smartphone to share its internet access wirelessly with your friends device which of the f
    10·1 answer
  • If you have a document that is relevant to more than one folder in your computer what should you do?
    8·1 answer
  • Assign jsonData with the parsed value of the stringData variable. Then, assign 29 to the points property in jsonData and assign
    13·1 answer
  • How does the speaker feel about traditional forms of poetry
    14·2 answers
  • In 1971, Intel created and marketed the first microprocessor chip, called the Intel 4004. What was significant about this invent
    7·1 answer
  • How to get the home button on your screen?
    13·1 answer
  • KAPWING Video Editing Software allows you to use existing You Tube Videos in your design.
    8·1 answer
  • Best practices and trends for technology integration
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!