Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Purpose:This lab will list the number of distinct words in Green Eggs and Ham and provide a count for how many times each is used.

Purpose:This lab will list the number of distinct words in Green Eggs and Ham and provide a count for how many times each is used. I will leave the implementation up to you. What I want is output file that looks like

do :35

anywhere :6

good :2

mouse :8

mot :1

Like :1

would :17

ham :10

me :4

Here is a textfile with the words. I would suggest you use a HashMap for this lab because a map is an object that maps keys to values. A map cannot contain duplicate keys; each key can map to at most one value.

The word would be the key and the value would start at 1 the first time you find the word in the file and then increment it each subsequent time you find the same word.

HASHMAP do not have duplicates You will need a try and catch to read a file.

Steps - use examples from Thursday

Lots of imports - file io and HashMap

Use try/catch to open file

Define a HashMap with a String key and an Integer value

Use while loop to read

text file:

I am Daniel

I am Sam

Sam I am

That Sam I am

That Sam I am

I do not like

That Sam I am

Do you like

Green eggs and ham

I do not like them

Sam I am

I do not like

Green eggs and ham

Would you like them

Here or there

I would not like them

Here or there

I would not like them

Anywhere

I do not like

Green eggs and ham

I do not like them

Sam I am

Would you like them

In a house

Would you like them

With a mouse

I do not like them

In a house

I do not like them

With a mouse

I do not like them

Here or there

I do not like them

Anywhere

I do not like green eggs and ham

I do not like them Sam I am

Would you eat them

In a box

Would you eat them

With a fox

Not in a box

Not with a fox

Not in a house

Not with a mouse

I would not eat them here or there

I would not eat them anywhere

I would not eat green eggs and ham

I do not like them Sam I am

Would you Could you

In a car

Eat them Eat them

Here they are

I would not

Could not

In a car

You may like them

You will see

You may like them

In a tree

I would not could not in a tree

Not in a car You let me be

I do not like them in a box

I do not like them with a fox

I do not like them in a house

I do mot like them with a mouse

I do not like them here or there

I do not like them anywhere

I do not like green eggs and ham

I do not like them Sam I am

A train A train

A train A train

Could you would you

On a train

Not on a train Not in a tree

Not in a car Sam Let me be

I would no could not in a box

I could not would not with a fox

I will not eat them with a mouse

I will not eat them in a house

I will not eat them here or there

I will not eat them anywhere

I do not like them Sam I am

Say

In the dark

Here in the dark

Would you could you in the dark

I would not could not

In the dark

Would you could you

In the rain

I would not could not in the rain

Not in the dark Not on a train

Not in a car Not in a tree

I do not like them Sam you see

Not in a house Not in a box

Not with a mouse Not with a fox

I will not eat them here or there

I do not like them anywhere

You do not like

Green eggs and ham

I do not

Like them

Sam I am

Could you would you

With a goat

I would not

Could not

With a goat

Would you could you

On a boat

I could not would not on a boat

I will notwill not with a goat

I will not eat them in the rain

I will not eat them on a train

Not in the dark Not in a tree

Not in a car You let me be

I do not like them in a box

I do not like them with a fox

I will not eat them in a house

I do not like them with a mouse

I do not like them here or there

I do not like them anywhere

I do not like

Green egss

And ham

I do not like them

Sam I am

You do not like them

So you say

Try them Try them

And you may

Try them and you may I say

Sam

If you will let me be

I will try them

You will see

Say

I like green eggs and ham

I do I like them Sam I am

And I would eat them in a boat

And I would eat them with a goat

And I will eat them in the rain

And in the dark And on a train

And in a car And in a tree

They are so good so good you see

So I will eat them in a box

And I will eat them with a fox

And I will eat them in a house

And I will eat them with a mouse

And I will eat them here and there

Say I will eat them anywhere

I do so like

Green eggs and ham

Thank you

Thank you

Sam I am

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

Focus On Geodatabases In ArcGIS Pro

Authors: David W. Allen

1st Edition

1589484452, 978-1589484450

More Books

Students also viewed these Databases questions

Question

Develop two use scenarios for the DFD in exercise E in Chapter 5.

Answered: 1 week ago

Question

Go to www.quikbook.com and critique the website.

Answered: 1 week ago

Question

What should be the role of managers in HRD?

Answered: 1 week ago