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
AVprozaik [17]
3 years ago
13

Write a program that replaces words in a sentence. The input begins with an integer indicating the number of word replacement pa

irs (original and replacement) that follow. The next line of input begins with an integer indicating the number of words in the sentence that follows. Any word on the original list is replaced. Ex: If the input is: 3 automobile car manufacturer maker children kids 15 The automobile manufacturer recommends car seats for children if the automobile doesn't already have one. then the output is: The car maker recommends car seats for kids if the car doesn't already have one. You can assume the original words are unique. For coding simplicity, follow each output word by a space, even the last one. Hint: For words to replace, use two vectors: One for the original words, and the other for the replacements. Your program must define and call the following function that returns index of word's first occurrence in wordList. If not found, then the function returns -1. int FindWordInWordList(vector wordList, string wordToFind)
Computers and Technology
1 answer:
kramer3 years ago
3 0

Answer: provided in the explanation segment

Explanation:

This is the code to run the program:

CODE:  

//Input: 3 automobile car manufacturer maker children kids

  //15 The automobile manufacturer recommends car seats for children if the automobile doesn't already have one.

  import java.util.Scanner;

  public class LabProgram{

  public static int findWordInWordList(String[] wordList, String wordToFind, int numInList) {

          for (int i = 0; i < numInList; i++) {

              if (wordList[i].equals(wordToFind)) {

                  return i;

              }

          }

          return -1;

      }

      public static void main(String[] args) {

          Scanner scan = new Scanner(System.in);

          String[] original_String = new String[20];

              String[] modified_String = new String[20];

          int numInList = scan.nextInt();

          for (int i = 0; i < numInList; i++) {

              original_String[i] = scan.next();

              modified_String[i] = scan.next();

          }

          int num_Of_Words = scan.nextInt();

          String[] words_To_Replace = new String[num_Of_Words];

          for (int i = 0; i < num_Of_Words; i++) {

              words_To_Replace[i] = scan.next();

          }

          int indx;

          for (int i = 0; i < num_Of_Words; i++) {

              indx = findWordInWordList(original_String, words_To_Replace[i], numInList);

              if (indx != -1)

                  words_To_Replace[i] = modified_String[indx];

          }

          for (int i = 0; i < num_Of_Words; i++)

              System.out.print(words_To_Replace[i] + " ");

          System.out.println();

      scan.close();

      }

  }

cheers i hope this helps!!!!1

You might be interested in
Prove that the dual of the exclusive-OR gate is also itscomplement
Tresset [83]

Answer:

Explanation:

The dual of a function means replace AND with OR and replace OR with AND.

XOR gate of A , B is

A \, XOR\, B = AB' + A'B

So, Dual of A XOR B is ( replace AND with OR and OR with AND)

= (A+B')(A'+B)

Complement of A XOR B is (A XOR B) ' = (AB' + A'B) ' = ((A)' + (B')') ((A')' + (B)') = (A'+B)(A+B') (In finding compliment AND becomes OR and OR becomes AND ).

By inter changing the above product of terms  

Complement of A XOR B = (A + B') (A' + B)

So, Dual of A XOR B = Complement of A XOR B.

7 0
3 years ago
Help please! Coding!
gladu [14]

Answer:

Explanation:

16

17

5 0
3 years ago
8. Software ____ are individual programs that can be purchased, installed, and run separately, but extract data from the common
oee [108]
System software are software that can be installed and run separately
6 0
2 years ago
Why is weather forecast so important for hang gliders?
professor190 [17]
Well, it wouldn't be such a good idea if they got caught up in a storm, would it? :p

Strong winds could blow them off-course, or even lightning has a chance of striking the hand glider, causing damage to the glider, the person, or even both.

Additionally, a weather forecast can help in my generic situations. For example, knowing whether to wrap up warm for cold weather, or wear something a bit more loose and breathable for hot weather.
6 0
3 years ago
How do you find the exterior angle measure of any regular polygon? (The degree in which to turn the turtle to draw a shape)
Diano4ka-milaya [45]

Answer:

360/number of sides

Explanation:

all the exterior angles add up to 360°

so to find each angle mesure, divide the 360 by the number of sides the figure has.

7 0
3 years ago
Other questions:
  • An electronic resume is a plain-looking document. True of False?
    6·2 answers
  • Write a program that prompts the user for a measurement inmeters and then converts it into miles, feet, and inches.
    9·1 answer
  • Stealing passwords by using software code to run through various password schemes with numbers, symbols, capital letters, and ch
    6·1 answer
  • Someone please help me with the right answer please
    12·1 answer
  • How would you justify using cloud computing?
    12·1 answer
  • Write a recursive function that returns true if the digits of a positive integer are in increasing order; otherwise, the functio
    15·1 answer
  • If there is only a stop sign posted at a railroad
    9·1 answer
  • Read the scenario and then answer the question using only the information provided.
    7·1 answer
  • 1.a computer can create an output based on the input of the user.
    13·1 answer
  • How do you get your winkey wet??
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!