g Write a program that allows a user to input any text in your program. Using the tools that we have discussed, your program should output how many unique words were in the input and then output how many words were unique.

Answers

Answer 1

Answer:

Explanation:

The following function/program is written in Java. It asks the user for a sentence as an input and then splits that sentence into an array of words. Then it creates an arrayList for all of the unique words, comparing each word in the sentence with all of those in the ArrayList. If a word is found in the ArrayList it cancels the loop and moves on the next word in the sentence. Finally, it counts all of the unique words in the ArrayList and prints that total to the screen.

public static void uniqueWords() {

       Scanner in = new Scanner(System.in);

       System.out.println("Enter a sentence:");

       String sentence = in.nextLine();

       String words[] = sentence.split(" ");

       ArrayList<String> uniqueWords = new ArrayList<>();

       for (int x = 0; x < words.length; x++) {

           boolean exists = false;

           for (int i = 0; i < uniqueWords.size(); i++) {

               if (words[x].equals(uniqueWords.get(i))) {

                   exists = true;

                   break;

               }

           }

           if (exists == false) {

               uniqueWords.add(words[x]);

           }

       }

       System.out.println(uniqueWords.size());

   }


Related Questions

Which view displays the records in columns and rows like excel worksheet​

Answers

Answer:

Datasheet View

Explanation:

Chapter 1

A B

Database Template A preformatted database designed for a specific purpose.

Datasheet View The Access view that displays data organized in columns and rows similar to an Excel worksheet.

Match the IP Protections Patent, Copyright and Trademark into the following cases:

a. books, poems
b. music, movies, paintings
c. company logo
d. software
e. combinations of materials to make drugs

Answers

Answer:

A) copyright

B) copyright

C)Trade mark

D) copyright

E)Patent

Explanation:

Patent can be regarded as a form of intellectual property which helps the owner of an invention to others to sell or use the invention for some period of time. Example of this is a patent that protect microwave oven.

trademark is form of intellectual property, this could be inform of symbols, words that differentiate the product of a party from another. Example of this is a bite of apple that represents apple products.

Copyright can be regarded as a legal right given to those that owns a intellectual property which gives him/her right to copy and exclude others from reaping from where they did not sow. The owner get exclusive right to reproduce the copy.

Below is the match of the intellectual property with the examples.

a. books, poems<> Copyright

b. music, movies, paintings<> Copyright

c. company logo<> Trademark

d. software<>Copyright

e. combinations of materials to make drugs<> patent

Consumers who pay more than the minimum payment on credit cards...
are crazy, why pay more than you need to?
O pay less interest in the long run.
O see their credit scores decrease.
are able to buy more things.

Answers

Pay less interest in the long run
Other Questions
Alfonso runs 10 km at an average speed of x km/h.The next day he runs 12 km at an average speed of (x - 1) km/h.The time taken for the 10km run is 30 minutes less than the time taken for the 12 km run.(a) (i)Write down an equation in x and show that it simplifies to x? 5x 20 = 0. WILL GIVE BRAINLIEST but you have to show your work Lighting for a location shot is run by the team at the location.TrueFalse 1. PART A: Which statement best expresses the central ideaof the text? help me pleaseeeeeeeeeeee Janka si vloila 3200 eur na termnovan et s 1,2 rokovou mierov koko bude ma po 1 roku Which phrase best completes the diagram?D. setting up local governments The least common denominator of[tex]\frac{1}{6} and \frac{5}{12}[/tex] is 12.TrueFalse Help Fast 5 paragraph esaay. What does it mean when you need to explain how your example and evidence tie into your topic Which piece of evidence best supports Schlosser's claim from theIntroduction to Fast Food Nation? Jorge's family arrived home at 8:00 at night after traveling in the car for 5 hours and 15 minutes. What time did Jorge's family leave? Two masses sit at the top of two frictionless inclined planes that have different angles,__deleted9917f34947e1359b5705bbac0d9227f8ec5df862078213a2db19c72f00189109deleted__ 0N86-C1-52-40-A837-22820 50% Part (a) What can be said about the speeds of the two masses at the bottom of their respective paths WILL MARK BRAINLIEST ONLY IF YOU SHOW WORKYou throw a ball upwards from a starting height of 0.0m with a velocity of 4.56m/s. a) What is the vi? b) what is the velocity when the ball reaches its highest point? c) What is the acceleration when you throw the ball? d) What is the acceleration at the balls highest point? e) What is the velocity right as the ball reaches your hand on its way back down? (Your hand is at di=0m) Please hurry no clown answers and please do the whole thingYou are a member of your local movie theaters club. Every time you see a movie at the theater, you earn 2 advantage points. When you earn 100 points, you get a free movie pass. Currently, you have 40 advantage points.Write an equation to model the number of movies m you have to watch before you earn a free movie pass.Solve the equation. Show your work. PLS HELP WILL GIVE BRAINLIEST AND POINTS PLS HELP A bird supply wholesaler wants to make a seed that costs $0.75 per pound out of 50 pounds of a $0.60 per pound seed and someamount of a $0.90 per pound seed. How much of the $0.90 per pound seed should the wholesaler use to make his 50.75 per poundseed?A)2 poundsB)30 poundsc)50 poundsD)60 pounds how here likes cats bc i think cats are cool How many solutions does 5 - 2x = 4 - 2x + 4 + x have?A. Infinitely many solutionsB. Two solutionsC. One solutionD. No solutions A store had a sale where you could get 5 bags of cashews for $4. If youwanted to buy 50 bags, how much would it cost? PLEASE HELP ME ITS THE LAST QUESTION ASAPfill in the blanksPor qu no ___ los verbos? Sin verbos no puedes hablar. list the criteria that describes BPD (borderline personality disorder?) please help me!!!!