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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 10:20, vuqepete4528
Shown below is the start of a coding region within the fist exon of a gene. 5'--3' 3'--5' how many cas9 pam sequences are present?
Answers: 1
image
Computers and Technology, 23.06.2019 19:00, nayo2006
Acompany is hiring professionals for web designing. the firm is small with few resources. they want employees who possess problem-solving skills and can independently carry out responsibilities. which kind of employee should they select?
Answers: 2
image
Computers and Technology, 23.06.2019 23:30, issacurlyheadka
A. in packet tracer, only the server-pt device can act as a server. desktop or laptop pcs cannot act as a server. based on your studies so far, explain the client-server model.
Answers: 2
image
Computers and Technology, 24.06.2019 15:50, coralaguilar1702
Andy would like to create a bulleted list. how should he do this? andy should click on the bullet icon or select the bullet option from the menu and then type the list. andy should press the shift key and the 8 key at the beginning of each line of text. andy should type the text and then click on the bullet command. andy should press return and the bullets will automatically
Answers: 2
You know the right answer?
Write a public static method named insert. The insert method should have the signature insert(String...

Questions in other subjects: