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
Wittaler [7]
2 years ago
14

Write a public static method named insert. The insert method should have the signature insert(String[] words, String newWord, in

t place), should return a boolean, and should function as described below.
When called, if place does not represent a valid index for words, then the method will return false to indicate the insertion could not be performed and do nothing else. Otherwise the method will insert the String newWord into the array words at the index place, moving each subsequent entry one place further and losing the final String in the array. The method will then return true to indicate the insertion has taken place.
Use the runner class to test this method: do not add a main method to your code in the U6_L4_Activity_One.java file or it will not be scored correctly.
Here is the runner code:
import java.util.Scanner;
public class runner_U6_L4_Activity_One{
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
System.out.println("Enter array length:");
int len = scan.nextInt();
scan.nextLine();
String[] wordList = new String[len];
System.out.println("Enter values:");
for(int i = 0; i < len; i++){
wordList[i] = scan.nextLine();
}
System.out.println("Enter new String:");
String insWord = scan.nextLine();
System.out.println("Enter place:");
int pos = scan.nextInt();
System.out.println("Method return: " + U6_L4_Activity_One.insert(wordList, insWord, pos));
System.out.print("Array contents: {");
for(int i = 0; i < len-1; i++){
System.out.print(wordList[i] + ", ");
}
System.out.println(wordList[len-1]+"}");
}
}
Computers and Technology
1 answer:
Mumz [18]2 years ago
5 0

Answer:

Explanation:

The following code was written in Java and performs the exact requirements listed in the question. It has also been tested by the runner code and works perfectly.

public static boolean insert(String[] words, String newWord, int place) {

               if (place > words.length) {

                   return false;

       } else {

                   for (int x = words.length - 1; x >= 0; x--) {

                       if (place == x) {

                           words[x] = newWord;

                           break;

                       } else {

                           words[x] = words[x-1];

                       }

                   }

                   return true;

               }

   }

You might be interested in
What electronic device can represent a KiloByte?
katovenus [111]

Military specifications often call for electronic devices to be able to withstand accelerations of 10 g. to make sure that their products meet this specification, manufacturers test them using a shaking table that can vibrate a device at various specified frequencies and amplitudes. if a device is given a vibration of amplitude 9.4 cm, what should be its frequency in order to test for compliance with the 10 g military specification? the acceleration of gravity is 9.81 m/s 2 .

7 0
3 years ago
The key schedule results in generating multiple keys from the one secret key. These multiple keys are used:
Helga [31]

Answer:

Option(d) is the correct answer to the given question .

Explanation:

There are various type of algorithm is used for the purpose of the key scheduling such as AES .in the AES algorithm we used same key for encryption and decryption of text .The  main objective of the AES algorithm it is used by Various round of the similar plain text encryption to reinforce the cipher text.

  • The Option (a) is wrong because In the key scheduling the creating keys are not being used one after just another in the various communication cycles.
  • The Option (b) is wrong because In the key scheduling  we do not used the  the random key for the encryption process .
  • The Option (c) is wrong because we will never arbitrarily subdivided into groups of public and private key.

3 0
2 years ago
I need help making a survey for highschool students in my school any topics/questions?
givi [52]

Answer:

depends is it just a survey? because if it doesent matter about the questions ou can do basic quuestions such as "what is your favorite video games" or "what is your favorite food"?

Explanation:

4 0
3 years ago
You have several marketing documents that are published through AD RMS. However, you have three new marketing employees that req
snow_lady [41]

Answer:

Document unauthorized

Explanation:

this way new employees will not try to open

5 0
3 years ago
Expand and simplify the following expressions. 1/2 [ 2x + 2 ( x - 3)] *​
Lerok [7]

Answer: 2

x

−

3

Explanation:

4 0
2 years ago
Other questions:
  • Utilities software and word processing software are both eamples of
    10·1 answer
  • Best value supply chains strive to excel along four measures: speed, quality, cost, and flexibility. Group of answer choices Tru
    10·1 answer
  • Which is the correct formula to add the values in cells A1 and B1? A. SUM(A1+B1) B. =SUM(A1+B1) C. =SUMA1+B1 D. A1+B1
    9·2 answers
  • When working in the middle of a presentation, how do you preview the slide show from the current slide?
    12·1 answer
  • What do you think was the immediate effect of the introduction of handheld consoles and video games?
    6·1 answer
  • Identify the benefit of modeling to communicate a solution.
    10·1 answer
  • Who is your favorite smite god in Hi-Rez’s “Smite”
    14·1 answer
  • What is the BCC feature used for?
    12·2 answers
  • To discover how many cells in a range contain values that meet a single criterion, use the ___ function
    5·1 answer
  • Disuss the roles of hardware,software and databases in regard to computer based information systems
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!