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
Text mining is a __________, while NLP is a __________. Method, Process Process, Process Process, Method Method, Method
Pie

The answer to text mining and NLP being either a method or a Process are; Text mining is a Process while NLP is a method

<h3>Understanding Text mining & NLP</h3>

NLP is a method whereby text, speech, images, signs, and other forms of natural human communication are all utilized to examine the grammatical structures that the end - user inputs and derives semantic meanings.

However, Text mining is a technique that is used for analyzing text documents by making use of qualitative analysis to extract the properties of the materials.

Read more about Text Mining at; brainly.com/question/25873249

5 0
2 years ago
rite a function to prompt the user to enter the information for one movie (title, release date, mpaa rating and number of stars)
vesna_86 [32]

Answer:

import java.util.*;

public class Movie {

   

   public static void main (String [] args) {

       

       System.out.println(movieInfo());

       

   }

   public static String movieInfo() {

       Scanner input = new Scanner(System.in);

       Scanner input2 = new Scanner(System.in);

       

       System.out.print("Enter the title: ");

       String title = input.nextLine();

       System.out.print("Enter the release date: ");

       String releaseDate = input.nextLine();

       System.out.print("Enter the mpaa rating: ");

       double mpaaRating = input2.nextDouble();

       System.out.print("Enter the number of stars: ");

       double numberOfStars = input2.nextDouble();

       

       return "Title: "+title+ "\nRelease Date: "+releaseDate+ "\nMPAA Rating: "+ mpaaRating+ "\nNumber of Stars: "+numberOfStars;

   }

}

Explanation

- Create a function called <em>movieInfo()</em> that returns a string, information about a movie

- Ask the user to enter the title, release date, mpaa rating and number of stars of the movie.

- Return these values at the end of the function

- Inside the main, call the function to see the information about the movie

7 0
4 years ago
An online game is played with two dice. In this context, explain what is meant by decomposition in a simple way.
pshichka [43]
Their value is random, so you need to generate two numbers between 1 & 6.
    You may need to display the numbers
    The main part of the program needs to know the numbers to limit what the user may do next.


That's most of the first level of decomposition. You need to keep decomposing (breaking into smaller simpler pieces) (think of an outline) and deciding what objects, functions, data structures and logic you're going to code this.
8 0
3 years ago
The two types of Desktop Publisher (DTP) frames for entering information are ... and ...​
Alekssandra [29.7K]

Answer:

digital pages and virtual paper pages

3 0
2 years ago
A group of students is performing an investigation to measure how much liquid water is produced from a 10 L sample of snow. What
Afina-wow [57]

Answer:

the temperature of the sample must change

Explanation:

7 0
3 years ago
Other questions:
  • Attacker player X is standing still on a corner kick, as the ball is played, he jumps up with his arms flailing above his should
    8·1 answer
  • Which letter indicates the amplitude of the wave?<br> a. A<br> b. B<br> c. C<br> d. D
    12·1 answer
  • In computers, when the print command is executed, a cable carries this signal from the computer to the printer. In comparing a c
    11·1 answer
  • The area between the main content page and the page edges
    9·2 answers
  • If the larger gear is the
    15·1 answer
  • Coding question. Please help me?
    7·1 answer
  • A TextLineReader is an object that can read a text file one line at a time, parsing each line and turning it into an object of s
    10·1 answer
  • I need this answered
    10·1 answer
  • What is communication ?? ​
    9·2 answers
  • What kind of cable would you use to connect a network printer to the soho router if you were using a wired connection to the net
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!