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
How to fix my pc from this
Ray Of Light [21]

Answer:

Restart it

Explanation:

6 0
3 years ago
Read 2 more answers
"what is the common information listed under the ip section of pdu details as compared to the information listed under the osi m
frez [133]

Solution:

The common information listed under the ip section of pdu details as compared to the information listed under the osi model tab is Packet Tracer.

This simulation activity is intended to provide a foundation for understanding the TCP/IP protocol suite and the relationship to the OSI model. Simulation mode allows you to view the data contents being sent across the network at each layer. As data moves through the network, it is broken down into smaller pieces and identified so that the pieces can be put back together when they arrive at the destination. Each piece is assigned a specific name (protocol data unit [PDU]) and associated with a specific layer of the TCP/IP and OSI models. Packet Tracer simulation mode enables you to view each of the layers and the associated PDU. The following steps lead the user through the process of requesting a web page from a web server by using the web browser application available on a client PC.  Even though much of the information displayed will be discussed in more detail later, this is an opportunity to explore the functionality of Packet Tracer and be able to visualize the encapsulation process.

This is the required answer.

7 0
3 years ago
In its entirety, the CCM process reduces the risk that ANY modifications made to a system result in a compromise to system or da
Tom [10]

Answer: True

Explanation: CCM process is the process which basically watches over any change or modification that is being made in the data and it will only be implemented when there is no adverse effect of the change.It procedure helps in reducing the risk due to any modification made in data of a system. CCM process also take care of the confidentiality of data and integrity as well and helps inn maintaining it.Therefore the given statement is true.

8 0
3 years ago
Which part of the computer coordinates all computer operations and performs arithmetic and logical operations on data
allochka39001 [22]

Answer:

A central processing unit (CPU) is the electronic circuitry within a computer that carries out the instructions of a computer program by performing the basic arithmetic, logical, control and input/output (I/O) operations specified by the instructions. The term has been used in the computer industry at least since the early 1960s.

5 0
3 years ago
Is a component that provides a button control in a gui application or applet?
harina [27]
<span>GUI is a graphical user interface. It is a graphical window that provides interaction with the user. 
</span>The button is a pushbutton, which can be pressed to trigger an action.<span>
A graphic control component or a control element is a component that provides a button control in a GUI application. It is also called a control element because it </span><span>is an element of interaction between the user controlling the application.</span>
7 0
4 years ago
Other questions:
  • . Electricians will sometimes call ______ "disconnects" or a "disconnecting means."
    12·1 answer
  • A(n) _______ is a collection of related data organized in a way that facilitates data searches.
    6·1 answer
  • how do I comment on answers? there's one answer I'm confused about but I don't know how to comment on it
    7·2 answers
  • The rules of thumb designers use when creating a wireframe page
    8·1 answer
  • Lee finishes entering all the data. Next, he wants to format the header row so it is easier to read and stands out from the rest
    11·1 answer
  • Type the correct answer in the box.
    15·1 answer
  • Package Newton’s method for approximating square roots (Case Study: Approximating Square Roots) in a function named newton. This
    7·1 answer
  • Consider the following definitions:public boolean someMethod (int[] list, int value){ int counter; boolean flag = false; for (co
    10·1 answer
  • Write a program that uses nested loops to collect data and calculate the average rainfall over a period of years. The program sh
    6·1 answer
  • What do u think a creative app must have? <br><br> Please answer the question ASAP!!
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!