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]
3 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]3 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
Management of software development consist of?
JulsSmile [24]

Answer:

d. All of the above

Explanation:

A software can be defined as a set of executable instructions (codes) or collection of data that is used typically to instruct a computer how to perform a specific task and to solve a particular problem.

A software development life cycle (SDLC) can be defined as a strategic process or methodology that defines the key steps or stages for creating and implementing high quality software applications.

In Computer science, management of software development consist of;

a. Process: it involves the stages through which a software application is analyzed, designed, developed, tested, etc.

b. People: it refers to the individuals involved in the software development process.

c. Project: it's the entirety of the stages a software goes through before it gets to the end user.

5 0
3 years ago
PLZZ HELP
kap26 [50]

Answer:

Explanation:

Keep in mind a lossy algorithm will lose information while a lossless algorithm maintains all your original information.

Therefore:

A. False, a lossy algorithm will not allow perfect reconstruction.

B. True, if you don't care about keeping all your information it's easier to compress.

C. False, you can use a lossless algorithm for anything.

D. False, the point of lossless is that you keep all information.

4 0
3 years ago
Whats your favorite .io game (example krunker.io, gawd.io)<br> (PS FWEE PTS BOIS)
marshall27 [118]

Answer:

starve.io

Explanation:

It's basically an entire game, you can play a single run for hours and it's all new content the entire way, not to mention it's actually difficult the entire way through.

4 0
2 years ago
What phrase best describes the overall structure of the<br> passage
creativ13 [48]

Answer: The one that gives you more vibe that its correct.

Explanation:

3 0
3 years ago
Mathematics and computer science share many concepts, such as recursion.
Virty [35]
The answer is B.

Read the answer I posted for your other question on the factorial of 7.
5 0
2 years ago
Other questions:
  • Suppose you have a certain amount of money in a savings account that earns compound monthly interest, and you want to calculate
    10·2 answers
  • The term composite would be used to describe an image that was altered by the Crop tool.
    15·1 answer
  • Which is a function of network media?
    11·2 answers
  • You are going to be installing a videoconferencing system. One of the requirements of the system is that only workstations that
    10·1 answer
  • If you “bury” a story on Digg, what have you done
    10·1 answer
  • What is your favorite food
    11·2 answers
  • Caleb is a big fan of science fiction, so he loves picturing the ________ gland as the captain of his personal starship, pulling
    9·1 answer
  • Which of the following statements about ip addresses is true?
    5·1 answer
  • We love silky. she is very honest join this by using conjunction ​
    11·2 answers
  • Which original VPN protocol is supported by most platforms but offers low levels of security?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!