Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Programming Assignment Instructions : In this assignment you will create your code from scratch. You are to create a C file named __hw4.c NOTE You

Programming Assignment

Instructions: In this assignment you will create your code from scratch.

You are to create a C file named __hw4.c

NOTE You may use C++ - but you MAY NOT use #include .

The goal is to use C-Style character array based strings. You will put all of your code in this file. You may use any technique we have learned so far.

Specifications:

The goal of this assignment is to create a dynamic version of Assignment 3. This assignment is split into several parts. The goal is to get you used to working with C/C++ compile-time arrays and strings.

Part 0 Create a Menu

You should create a menu that gives access to each of the parts of the assignment. Show this menu and make it function properly. If the user inputs something incorrect, correct them and loop the menu and prompt.

Welcome to Assignment 3!

Menu:

1 Single Dimension Array Processing

2 Two-D Processing

Choose an option:

Part 1 Single Dimension Array

Write a void function to drive Part 1.

A Filling the array) Ask the user for a size and dynamically allocate the array based on that size. This is going to be a fixed size array. Initialize the array to contain all \0 characters. Write a function to fill the array with random lower-case letters. Prototype example: void fillArray(char* letters, int size);

B Menu) Give the user a menu of options to process the array:

1. Check frequency of a letter

2. Remove a letter

3. Sort

C Processing)

Menu Option 1 Get a character from the user. Either safety-check it, or force it to be lowercase. Create a function that returns an integer. This function should take the array, the letter and the size.

Prototype: int getFrequencyOf(char letters*, int size, char item);

You will loop through the array and count each matching instance of the character the user inputted. Return the final count. Output the result and ask if they want to do another process.

Menu Option 2 Get a character from the user.

Either safety-check it, or force it to be lowercase. Create a function that will remove ALL instances of the specified character from your array.

Prototype: void removeCharacter(char letters*, int size, char item);

This should not leave gaps in your array. Make sure you shuffle down the contents of the array to fill in the gaps. Make sure you properly place the \0 After processing the array, output the array with a printf(%s) statement to prove you processed it correctly. Ask if they want to do another process.

Menu Option 3 Write a function to sort the array alphabetically.

Extra Credit opportunity create an O(n log n) algorithm +3 points.

Prototype: void sortArray(char letters*, int size); NOTE Think about when this might be called. Has the user removed any letters?

Part 2 2D Processing

Part 2 will have you doing the single dimensional operations to a 2D array of strings. Write a void function to drive Part 2. Part 2 starts by asking the user how many strings they want to create and the max length of the strings. Each of these string will be put in a row of their own in a 2D character array. Remember to end each row with a \0. After you have received the inputs output the strings to confirm they were inputted correctly.

Give the user a menu of options to process the array:

1. Check frequency of a letter

2. Remove a letter

Apply the operation the user selects to ALL of the strings in the 2D array. Each time an operation finishes output the results for each row. NOTE if you coded part 1 correctly, this section can and will make use of the exact same functions you coded earlier!

Sample Output:

Welcome to Assignment 3!

Menu:

1 Single Dimension Array Processing

2 Two-D Processing

Choose an option:

User choose 1:

Choose an option: 1

How many characters? 60

Filling the array!

phqghumeaylnlfdxfircvscxggbwkfnqduxwfnfozvsrtkjprepggxrpnrvystmwc

What would you like to do?

1. Check frequency of a letter

2. Remove a letter

3. Sort

>>?

User chooses 1:

>>? 1

What letter? g

There are 5 of the letter g (take the user back to the menu)

User chooses 2:

>>? 2

What letter? g

phqhumeaylnlfdxfircvscxbwkfnqduxwfnfozvsrtkjprepxrpnrvystmwc

g has been removed (take the user back to the menu)

User chooses 3:

>>? 3

Sorting!

abcccddeefffffhhijkkllmmnnnnoppppqqrrrrrsssttuuvvvwwwxxxxyyz (take the user back to the menu)

From Main Menu User chooses 2:

Choose an option: 2

How many strings do you want to enter? 11

What is the max size of the strings? 10

Enter string 1: testing

Enter string 2: apple

Enter string 3: document

Enter string 4: computer

Enter string 5: science

Enter string 6: banana

Enter string 7: orange

Enter string 8: sugar

Enter string 9: classes

Enter string 10: fancy

Enter string 11: flakes

What would you like to do?

1. Check frequency of a letter

2. Remove a letter

>>?

User chooses 1:

>>? 1

What letter? a

testing - 0

apple - 1

document - 0

computer - 0

science - 0

banana - 3

orange - 1

sugar - 1

classes - 1

fancy 1

flakes - 1

User chooses 2:

>>? 2

What letter? a

testing

pple

document

computer

science

bnn

ornge

sugr

clsses

fncy

flkes

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

Joe Celkos Data And Databases Concepts In Practice

Authors: Joe Celko

1st Edition

1558604324, 978-1558604322

More Books

Students also viewed these Databases questions

Question

2. What is the meaning and definition of Banking?

Answered: 1 week ago

Question

3.What are the Importance / Role of Bank in Business?

Answered: 1 week ago

Question

Use a three-step process to develop effective business messages.

Answered: 1 week ago