Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

Microsoft Word - A2.docx CIS*2500 Assignment 2: stringMe Weighting: 9% 1.0 Your Task Congratulations! You have been hired as a developer for this company called stringMe. As the sole...

2 answer below »
Microsoft Word - A2.docx
CIS*2500 Assignment 2: stringMe
Weighting: 9%
1.0 Your Task
Congratulations! You have been hired as a developer for this company called stringMe.
As the sole software developer of this product, you will create a li
ary of string
functions that are customized for this company.
The required files that you have to create are:
1. Header file: name it lastnameFirstnameA2.h
This file must include all function prototypes, global constants and any struct definitions.
2. Implementation file: name it lastnameFirstnameA2.c
This file must include all function definitions. The required functions and their description
are given later in this section. You are also free to create helper functions, though if they
are used by the assignment functions below, include them in lastnameFirstnameA2.c
and lastnameFirstnameA2.h so they are accessible to us during grading.
3. Testing file: name it lastnameFirstnameA2Main.c
4. A makefile: Your program will be compiled using a makefile with the following flags:
-std=c99 -Wall
Note that grading will be based on the specified function definitions. You are still
encouraged to make a robust testing file (lastnameFirstnameA2Main.c ) containing a
main(). Read Section 2.0.1 for more on what to include and what not to include.
5. Requirement on the folder structure of source, header and executable files –
ead Section 2.0.2 for details. /*\ Note that this is a new requirement (was not
equired for L1, L2 or A1)
Prototypes for the required Functions
char * readFile (char * filename);
This function takes a filename of a text file as input, opens and reads the contents of the
file and returns the contents as a string (char *). Note that you are required to use
dynamic allocation, so that the returned string is on a heap. For example, if the input
file is test1.txt, then this function returns a char * that holds the following characters
(given in red):
The red readymade dress was made for you! It was going to be ready tomo
ow.
What was the colour of the dress? Oh, it was red!
You will find this text file (test1.txt) and 2 other test files (test2.txt and test3.txt) in the
assignment folder on Courselink. Use them for testing. File test1.txt has 77 characters,
test2.txt has 129 characters and test3.txt has 732 characters.
void dejaVu (char * aString, int * numWords, int * numSentences);
This function takes a string as input, and outputs the number of words and number of
sentences in it. A word is any sequence of characters delimited by white space or the
end of a sentence, whether or not it is an actual English word. A sentence is a group of
words terminated by a period, colon, semicolon, question mark, or exclamation mark.
Multiples of each of these characters should be treated as the end of a single sentence.
For example, “Fred says so!!!” is one sentence.
For example, if the input string is:
The red readymade dress was made for you! It was going to be ready tomo
ow.
What was the colour of the dress? Oh, it was red!
Output is:
Number of words = 26
Number of sentences = 4
char * goBig (char * aString);
This function takes a string as its only parameter. It prompts the user to enter exactly n
valid positive integers, where n is the length of aString. Entering a 0 or negative is
considered invalid. The function then creates a new string that consists of the letters in
aString (in the same order) – each letter repeated by the number of times indicated by
the user for that co
esponding position.
For example,
if the function takes "hello!" as its argument, and the user enters the following 6 values:
XXXXXXXXXX, then the function creates and returns a stretched string as
Heelllllo!!
Note that the given string may have digits, alphabets, spaces and special characters
such as period, colon, semicolon, question mark, or exclamation mark.
The new stretched string must be created on a heap using dynamic memory allocation.
Use malloc() and realloc() functions to allocate only as much memory as required.
char ** goAway (char * aString, int * numWordsReturned);
This function takes a string aString, splits it into n words, stores the words in a
dynamic 2D a
ay and returns it. The function also outputs the total number of words
stored in the given input aString.
Note that a word is any sequence of characters separated by one or more spaces or a
newline. Special characters such as period, colon, semicolon, question mark, or
exclamation mark are considered a part of a word, unless separated by a space. For
example, total number of words in "Oh, it was red!" is 4. Similarly, in "Oh, it was red!"
is also 4. But the total number of words in "Oh , it was red!" is 5. Similarly, the total
number of words in the string read from file test1.txt is 15 and from test2.txt is 26.
The returned 2D string must be created on a heap using dynamic memory allocation.
Use malloc() and realloc() functions to allocate only as much memory as required.
char *
eathless (char * aString);
This function takes a string aString, finds all punctuations in the given string and
emoves them from aString. The function returns the string with punctuation removed.
Note that this assignment considers the following as punctuations:
period, colon, semicolon, question mark, or exclamation mark
For example, if the input string (length = 49) is
What was the colour of the dress? Oh, it was red!
the function returns the shorter string (length = 48 now)
What was the colour of the dress Oh, it was red
void tail (char * aString, int whichWord, char * desiredSuffix)

This function takes a string as a parameter, finds the word given in position whichWord
and prints n number of words on the standard output, where n is the length of the word
at position whichWord. Each word printed on the screen starts with a letter in the word at
position whichWord and is suffixed by desiredSuffix. For example, if aString is “Now
is the winter of our discontent Made glorious summer by this Sun of
York.”, whichWord is 8 and desiredSuffix is “otter”, then the words printed are
Motter
aotter
dotter
eotte
2.0 Compilation
Your program will be compiled using a makefile with the following flags:
-std=c99 -Wall
In grading this assignment, we may use our own main() function to facilitate testing,
although you are required to submit your main in a file called
‘lastnameFirstnameA2Main.c’.
If you do not plan on implementing every function, stub it out (create the definitions in
your lastnameFirstnameA2.c and lastnameFirstnameA2.h files and return a
meaningless value if it requires one). Otherwise, your submission will not compile with
our grader and you will get a 0.
2.0.1 Files required:

• lastnameFirstnameA2.c — your function implementations. You must submit
this.
• lastnameFirstnameA2.h — your function definitions/prototypes, constants,
li
ary imports, student info, and declaration of academic integrity. You must
submit this.
• lastnameFirstnameA2Main.c — your testing file/driver program used to verify
outputs/test your functions. This file would contain a main(). You must submit
this.
• Makefile - You must submit this.
The main target in your makefile must be called stringMe. Note that your
makefile is required to have a target called clean, that allows to remove all
object files and the executable file (stringMe). Read section 2.0.2 for more
details on makefile.
2.0.2 Required folder structure for this assignment
A2 folder tree structure (assume that the cu
ent folder is called A2)
A2 $
Folder src must contain your source file (i.e., lastnameFirstnameA2.c).
src include bin
Folder include must contain your header file (i.e., lastnameFirstnameA2.h)
Folder bin must contain your executable file (i.e. stringMe)
Note that the makefile should be located in the top-level directory (e.g. in folder A2). The
commands in makefile must call your source, header and executable files via relative
path. For example, the dependencies and commands to compile
lastnameFirstnameA2Main.c using the above folder structure will be:
lastnameFirstnameA2Main.o: src/lastnameFirstnameA2Main.c include/lastnameFirstnameA2.h
gcc -Wall -std=c99 -c src/lastnameFirstnameA2Main.c
Also note that all .o object files are created in the cu
ent folder (i.e. in folder A2),
whereas the executable is created in folder bin. Remember this when you write the
target for clean.
2.0.3 Running
Running such a program would be done as follows:
.
in/stringMe

For example, if the input text file is text1.txt, then your program will be run as
.
in/stringMe test1.txt
3.0 Testing
In lastnameFirstnameA2Main.c file, you are still strongly encouraged to test
throughout the entirety of the development lifecycle of this program.
4.0 Submission
You will submit your assignment files (lastnameFirstnameA2.c,
lastnameFirstnameA2Main.c makefile, and lastnameFirstnameA2.h) to A2
submission folder in GitLab.
Read / Watch the tutorial on gitlab to recall the process of submission.
Your lastnameFirstnameA2.h header file will contain a program header comment
signifying your academic integrity. It will be of the following form:
*
Student Name: Firstname Lastname
Student ID: #######
Due Date: Mon Day, Year
Course: CIS*2500

I have exclusive control over this submission via my password.
By including this header comment, I certify that:
1) I have read and understood the policy on academic integrity.
2) I have completed Moodle's module on academic integrity.
3) I have achieved at least 80% on the academic integrity quiz
I assert that this work is my own. I have appropriate acknowledged
any and all material that I have used, be it directly quoted or
paraphrased. Furthermore, I certify that this assignment was written
by me in its entirety.
*/

5.0 Marking
• Programs that don't compile receive an immediate zero (0).
• Programs that produce compilation warnings will receive a deduction of 1 mark
per unique warning (i.e., 3 'unused variable' warnings will only deduct 1 mark).
• Loss of marks may also result from poor style (e.g., lack of comments, structure)
• Programs that use goto statements receive an immediate zero (0)
• Programs that use global variables statements receive an immediate zero (0)
Note: Folder images are Licensed by Creative Commons 4.0 BY-NC


Now is the winter of our discontent
Made glorious summer by this
Sun of York.

The red readymade dress was made for you! It was going to be ready tomo
ow. What was the colour of the dress? Oh, it was red!
Answered 7 days After Feb 21, 2023

Solution

Nidhi answered on Feb 28 2023
37 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here