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
Write a function that accepts an argument for a persons name. The method should loop through the number of characters in the nam
MatroZZZ [7]

Answer:

#include <iostream>

#include<string.h>

using namespace std;

void printCharacter(string name){

   for(int i=0;name[i]!='\0';i++){

       cout<<name[i]<<endl;

   }

}

int main()

{

   string name;

   cout<<"enter the name: ";

   cin>>name;

   printCharacter(name);

}

Explanation:

first include the two libraries iostream for input/output and string library for using the string.

then, create the main function and declare the variable type string.

cout instruction is used o display the message on the screen.

cin is used to store the value in the name variable.

after that, call the function. The program control move to the the function. In the function for loop is used to print the character one by one until end of the name.

4 0
3 years ago
When performing actions between your computer and one that is infected with a virus, which of the following offers No risk of yo
daser333 [38]

Answer:

d

Explanation:

7 0
3 years ago
What makes jambinai so unique (it’s for band)
Rus_ich [418]

Answer:

Jambinai combines Korean folk music instruments and rock music instrumentation, which creates a different music style.

7 0
2 years ago
Write a Python function to determine the volume of material remaining after the hole is drilled. The function should take as inp
Andru [333]

Answer:

height = int(input ("Enter height : ") )

print (height)

width = int( input("Enter length : ") )

print (width)

half_width =width/2

half_height=height/2

while 0==0:

   radius = float( input("Enter radius : ") )

   print (radius)

   

   if radius<half_width and radius <half_height:

       break

def remainingVolume(height,width,radius):

       

   vol_box=height*width*width

   print (vol_box)

   vol_hole=3.14178*radius*radius*height

   print (vol_hole)

   

   remaining_vol=vol_box-vol_hole

   print ("Remaining volume is ",remaining_vol)

   

remainingVolume(height,width,radius);

Explanation:

Take input from user for height ,width and radius. To find volume of box formula is vol=height* width*length\\

Let's assume width and length is same so

length= width

Using this formula of box volume find box volume.Now find volume of hole.

Consider hole as small cylinder, find volume of cylinder and subtract from volume of box to get remaining volume of box after hole.

vol_of_cyl=\pi radius^{2} height

5 0
3 years ago
Suppose your school’s computer lab provides high-end architecture software that can be accessed from any lab computer, but a max
LenKa [72]

Answer:

Multiple-user licence.

Explanation:

A multiple-user licence allows the software to be accessed by the maximum number of users specified within the licence. In this scenario, it is 5 students, the connections are concurrent, meaning at any given time there can only be five users running the software. The software can be installed on more than 5 computers, but the number of active users is limited to 5.

3 0
2 years ago
Other questions:
  • In the INSERT statement that follows, assume that all of the table and column names are spelled correctly, that none of the colu
    9·1 answer
  • What are the 21St century competencies or skills required in the information society?<br>​
    15·1 answer
  • Write a Python program to do the following:
    12·1 answer
  • Helping people keep track on things is the purpose of_____ A database B table C query D form​
    12·1 answer
  • Big data refers to huge collections of data that are difficult to process, analyze, and manage using conventional data tools. It
    13·1 answer
  • ______ are used to store all the data in a database.
    7·1 answer
  • .- Una tienda de vestidos de fiesta, ofrece un descuento a las personas
    15·1 answer
  • Which of the following technologies does NOT facilitate the transferring of data between computers in adjacent buildings?
    12·1 answer
  • Luis saves an attachment that he received from Kevin. Where will the attachment save by default?
    5·1 answer
  • Discuss the concept of the “state of a process”. Give examples to illustrateyour answers?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!