Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this lab you are to write a program to find all words used in a text. This program will keep asking the user to

In this lab you are to write a program to find all words used in a text. This program will keep asking the user to type a text string. (This is in c++). For example, if the user inputs the following text:

Have a good day. Have a good class. +Have a good visit. Have fun!

You will do this program two different ways:

You will use a Set to contain the tokens obtained from the input text string, iterate over the contents of the Set and output the results.

You will use a UnorderedSet to contain the tokens obtained from the input text string, iterate over the contents of the UnorderedSet and output the results.

For example, the set of tokens of the above text string will be set tokens={ , . , +, ! }

Or might be unorderedset contains the tokens.

Next you will write a program that counts the occurrences of words in a text (use the same text as before) and displays the words and their occurrences in ascending order of words. The program will use a Map to store a pair consisting of a word and its count. For each word, check whether it is already a key in the map. If not, add the key and value 1 to the map. Otherwise, increase the value for the word (key) by 1 in the map. Iterate over the Map to output the data in ascending order.

For example, the map of the above text string might look like the following:

have 4

a 3

good 3

day 1

class 1

visit 1

fun 1

your program can run multiple times, give the user to input a text string or quit the program.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Systems

Authors: Ramez Elmasri, Shamkant B. Navathe

7th Edition Global Edition

1292097612, 978-1292097619

More Books

Students also viewed these Databases questions

Question

What is the central issue of the situation facing the organization?

Answered: 1 week ago