subject

Write a public static method named insert. The insert method should have the signature insert(String[] words, String newWord, int 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]+"}");
}
}

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 13:00
Write a program which asks you to enter a name in the form of first middle initial last. so you might enter for example samuel p. clemens. use getline to read in the string because it contains spaces. also, apparently the shift key on your keyboard doesn’t work, because you enter it all lower case. pass the string to a function which uses .find to locate the letters which need to be upper case and use toupper to convert those characters to uppercase. the revised string should then be returned to main in the form last, first mi where it will be displayed.
Answers: 1
question
Computers and Technology, 22.06.2019 15:30
Melissa needs to add a topic to an email that she will send to her teacher. choose the name of the field where she should type her topic.
Answers: 2
question
Computers and Technology, 23.06.2019 01:30
In deadlock avoidance using banker’s algorithm, what would be the consequence(s) of: (i) a process declaring its maximum need as maximum possible for each resource. in other words, if a resource a has 5 instances, then each process declares its maximum need as 5. (ii) a process declaring its minimum needs as maximum needs. for example, a process may need 2-5 instances of resource a. but it declares its maximum need as 2.
Answers: 3
question
Computers and Technology, 23.06.2019 16:00
What is the biggest difference between section breaks and regular page breaks? section breaks are more difficult to add than page breaks. section breaks make it easier for you to view the document as an outline. section breaks allow you to have areas of the document with different formatting. section breaks are smaller than regular page breaks.
Answers: 2
You know the right answer?
Write a public static method named insert. The insert method should have the signature insert(String...
Questions
question
Mathematics, 25.11.2020 22:10
question
Mathematics, 25.11.2020 22:10
Questions on the website: 13722363