Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in C please read amendments Text book : C How to program 8 th Edition Amendments Instead of reading several lines of text, just hard-code

in "C" please read amendments

image text in transcribed

Text book : C How to program 8th Edition

Amendments

Instead of reading several lines of text, just hard-code the following text in the program

myString= The quick Brown Fox jumps over the Lazy Dog and the !##! LAZY DOG is still sleeping.

Use a very small set of text to test/debug your program first.

The program should make use of a function that converts the text to lower case and then perform the analysis in the main function. Ignore any numbers, symbols or special characters, etc in the text if any.

Instead of the three methods outlined in the original question, complete only part a and part b. Assume maximum length is 10 for part b.

Output

Original text: The quick Brown Fox jumps over the Lazy Dog and the !##! LAZY DOG is still sleeping

Modified text: the quick brown fox jumps over the lazy dog and the lazy dog is still sleeping

Letter Count

a 2

b 1

Word length Occurrences

0

1

Required:

Use two 2 dimensional arrays to emulate the tables that will capture the result of the analysis. One for part a and another for part b.

Use loops to initialize the array values.

Indent your code/ provide comments when implementing somethings that require some logic.

Do not use 26 if statements to check for each letter. Use range of the alphabet (like between the starting and ending ASCII value of the letters).

Create a function that will

Accept two strings: target and source

Copy from source to target; process only A-Z and a-z, converting all upper case letters to lower case and ignoring everything else.

Hints:

Part a.

Since we have 26 letters, then we can use an array with 26 rows. Each row can hold value for the actual letter and another value for the count.

//Create an two dimensional array like below. You can use char instead of int to keep track of count too!

char letter_count_array[26][2]; // 26 rows & 2 columns

The following statements assign to the first row, the letter a to the first column and 5 to the second column. This represents the letter a was used 5 times in the sentence.

letter_count_array[0][0]=a;

letter_count_array[0][1]=5;

The following statements assign to the last row, the letter z to the first column and 3 to the second column. This represents the letter z was used 3 times in the sentence.

letter_count_array[25][0]=z;

letter_count_array[25][1]=3;

When populating the table a) with letters and table b) with word length, use loops. Use the loop iterator, the ASCII value of the letter and some mathematical operation to determine which bucket (row) of the array needs to updated. Do not use 26 comparison and/or assignment statements like shown below.

When try to figure out the letter occurrences, consider the following.

Assuming array word contains the modified sentence and the second column of letter_count_array is used to keep of the letter occurrences (count).

if (word[i] == a)

letter_count_array[0][1]++;

else if (word[i] == b)

letter_count_array[1][1] ++;

else if (word[i] == c)

letter_count_array[2][1]++;

..

.

else if (word[i] == z)

letter_count_array[25][1]++;

Avoid the above mentioned technique. Instead of the 26 conditional/assignment statements, the replacement code segment should look like the following 1 conditional/assignment statement.

Figure out / calculate ?, ?? and ??? where ??? must be between 0 and 25 ( 25 is the row limit!)

if (word[i] >= ? && word[i]

letter_count_array[???][1]++;

What happened to letter_count_array[???][0] ?

The 0 column keeps the actual letters a-z!

Each letter corresponds to a numeric value (see the ASCII chart for this) which should be used in the calculation of ???.

8.31 (lext Analysis) The availability of computers with string-manipulation capabilities has re sulted in some rather interesting approaches to analyzing the writings of great authors. Much atten tion has been focused on whether William Shakespeare ever lived. Some scholars find substantial evidence that Christopher Marlowe actually penned the masterpieces attributed to Shakespeare. Re- searchers have used computers to find similarities in the writings of these two authors. This exercise examines three methods for analyzing texts with a computer. a) Write a program that reads several lines of text and prints a table indicating the number of occurrences of each letter of the alphabet in the text. For example, the phrase To be, or not to be: that is the question contains one a," two "bs," no"c's," and so on. Write a program that reads several lines of text and prints a table indicating the number of one-letter words, two-letter words, three-letter words, and so on, appearing in the text. For example, the phrase b) hether 'tis nobler in the mind to suffer contains Word length Occurrences i 2 (including 'us) 8.31 (lext Analysis) The availability of computers with string-manipulation capabilities has re sulted in some rather interesting approaches to analyzing the writings of great authors. Much atten tion has been focused on whether William Shakespeare ever lived. Some scholars find substantial evidence that Christopher Marlowe actually penned the masterpieces attributed to Shakespeare. Re- searchers have used computers to find similarities in the writings of these two authors. This exercise examines three methods for analyzing texts with a computer. a) Write a program that reads several lines of text and prints a table indicating the number of occurrences of each letter of the alphabet in the text. For example, the phrase To be, or not to be: that is the question contains one a," two "bs," no"c's," and so on. Write a program that reads several lines of text and prints a table indicating the number of one-letter words, two-letter words, three-letter words, and so on, appearing in the text. For example, the phrase b) hether 'tis nobler in the mind to suffer contains Word length Occurrences i 2 (including 'us)

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

Step: 3

blur-text-image

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

Online Market Research Cost Effective Searching Of The Internet And Online Databases

Authors: John F. Lescher

1st Edition

0201489295, 978-0201489293

More Books

Students also viewed these Databases questions

Question

=+ Are you interested in creating or

Answered: 1 week ago

Question

=+working on a micro-multinational?

Answered: 1 week ago