C++ Programming Code

User Generated

koynpx99

Computer Science

Description

Hi,

Here's a description of the code:

For this assignment you will be writing a function: 

LetterCounter countLetters(int numStrings, char** stringList).

The return type is a class named LetterCounter (more on this later) containing an array with the counts for each of the 26 letters, normalized to lower case,  as well as another integer member for the total number of letters counted. The parameter int numStringsgives the length of the array of string pointers in char** stringList.

Requirements

You will be creating a project with 3 files that MUST be exactly named (capitalization and all):

  1. LetterCounter.cpp

  2. LetterCounter.h

  3. TestDriver.cpp (this file will be given to you)


You will be writing 1 function that MUST be exactly named (capitalization and all):

  1. LetterCounter countLetters(int numStrings, char** stringList)

Each File Serves the following purpose:

LetterCounter.h

LetterCounter.h will contain your class declaration as well as your function declaration.

LetterCounter.cpp

LetterCounter.cpp will contain your LetterCounter countLetters(int numStrings, char** stringList) definition. You do not need to write separate definition for your class (the declaration is enough). You function should operate as described below. Remember that classes are way for us to define our own data types so the return type of this function is LetterCounter.

The function you write serves a purpose

LetterCounter countLetters(int numStrings, char** stringList);


The parameters to the function will have the following memory model:


With these inputs you will iterator over each string in char** stringList and then iterate over each character in that string, incrementing the count for each individual normalized alphabetic character. Non-alphabetic characters should be ignored.  To normalize characters you may use your function from PSA[2> or you may use the “char tolower(char input)” function provided by the C++ language. Remember the number of strings you are iterating over is given as by the int numStrings parameter.


The return type is a class you will declare in your header file. It contains two members:

  1. int totalLettersCounted

    • This is the total number of letter counted across all strings in the list

  2. int letterCounts[26]

    • This is an array containing the counts for each individual letter.

    • ‘a’ is in index 0, ‘b’ is in index 1, ‘c’ is index 2 etc.


It’s memory model will look like this with 5 letters counted total: 2 a’s, 1 y and 2 z’s):

Is int numString positive? Is the parameter char** stringList NULL? Make sure to check these things before trying to use them!

ALSO MAKE SURE YOU TEST YOUR INPUTS TO MAKE SURE THEY MAKE SENSE!

Is int numString positive? Is the parameter char** stringList NULL? Make sure to check these things before trying to use them!


For this assignment I will also be providing your with a test driver TestDriver.cpp. This file will contain the main() function and will use your code to get the letter frequencies of a given list of strings. It will then print this output to the screen. Note that this is just a sample input and when we are actually grading this assignment we will be using other inputs as well.  


TestDriver.cpp can be located here: TestDrive.cpp

https://drive.google.com/file/d/0ByzTlffqfUOBZkFobGFmWU1RUHM/view?pli=1


User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

This question has not been answered.

Create a free account to get help with this and any other question!

Similar Content

Related Tags