fbpx

Computer Science Assignment | College Homework Help

For this assignment, download the A6 code pack. This zip file contains several files:

Don't use plagiarized sources. Get Your Assignment on
Computer Science Assignment | College Homework Help
Just from $13/Page
Order Now
  • main.cpp – the predetermined main.cpp. This file shows the usage and functionality that is expected of your program. You are not allowed to edit this file. You will not be submitting this file with your assignment.College Homework Help
  • CMakeLists.txt – the preset CMake file to build with your functions files.
  • input/greeneggsandham.txt – the contents of Green Eggs and Ham in text format.
  • input/aliceChapter1.txt – the first chapter of Alice in Wonderland in text format.
  • output/greeneggsandham.out – the expected output when running your program against the greeneggsandham.txt file
  • output/aliceChapter1.out – the expected output when running your program against the aliceChapter1.txt file

 

Your task is to provide the implementations for all of the referenced functions. You will need to create two files: functions.h and functions.cpp to make the program work as intended.

You will want to make your program as general as possible by not having any assumptions about the data hardcoded in. Two public input files have been supplied with the starter pack. We will run your program against a third private input file.

Function Requirements

The requirements of each function are given below. The input, output, and task of each function is described. The functions are:

  1. promptUserForFilename()
  2. openFile()
  3. readWordsFromFile()
  4. removePunctuation()
  5. capitalizeWords()
  6. filterUniqueWords()
  7. alphabetizeWords()
  8. countUniqueWords()
  9. printWordsAndCounts()
  10. countLetters()
  11. printLetterCounts()
  12. printMaxMinWord()
  13. printMaxMinLetter()

promptUserForFilename()

Input: None

Output: A string

Task: Prompt the user to enter a filename.

openFile()

Input: (1) The input file stream (2) The string filename to open

Output: True if the file successfully opened, False if the file could not be opened

Task: Open the input file stream for the corresponding filename. Check that the file opened correctly. The string filename will remain unchanged.

readWordsFromFile()

Input: The input file stream

Output: A vector of strings

Task: Read all of the words that are in the filestream and return a list of all the words in the order present in the file.

removePunctuation()

Input: (1) A vector of strings (2) A string of all the punctuation characters to remove

Output: None

Task: For each word in the vector, remove all occurrences of all the punctuation characters denoted by the punctuation string. When complete, the input vector will now hold all the words with punctuation removed. The punctuation string will remain unchanged.

capitalizeWords()

Input: A vector of strings

Output: None

Task: For each word in the vector, convert each character to its upper case equivalent. When complete, the input vector will now hold all the words capitalized.

filterUniqueWords()

Input: A vector of strings

Output: A vector of strings

Task: The function will return only the unique words present in the input vector. The output vector will not contain any duplicate words.

alphabetizeWords()

Input: A vector of strings

Output: None

Task: Sort the strings in the input vector alphabetically. When complete, the input vector have the same length and contents but reordered so that the contents are in alphabetical order.

countUniqueWords()

Input: (1) A vector of strings representing all of the words in the file (2) A vector of strings representing only the unique words in the file

Output: A vector of unsigned integers

Task: For every unique word in the list, count the number of occurrences the unique word is present in the full text. Return a vector of all the counts. Each position in the vector of counts corresponds to the same position in the unique word list. The vector of counts will have the same size as the vector of unique words. Upon completion, neither input vector will be modified.

printWordsAndCounts()

Input: (1) A vector of strings (2) A vector of unsigned integers

Output: None

Task: For each word and count in the vectors, print out the word and its corresponding count. Upon completion, the two vectors will remain unchanged. Format the output as follows:

#P : ABCDEF : #C

Notice how there are three columns separated by :. We want the : aligned in every row and the values aligned in each column. The columns correspond to the following values:

  1. #P – The position the word in the list. Begin at 1. Right align all values. Allocate enough space for the length of the last position. (If there are less than 10 numbers, then we need only 1 space. If there are less than 100 numbers, then we need only 2 spaces. And so on. Assume there will be at most 109 unique words.)
  2. ABCEDF – The unique word. Left align all values. Allocate enough space for the longest word present in the list.
  3. #C – The corresponding count of the unique word. Right align all values. Allocate enough space for the length of the largest number. (Assume there will be at most 109 unique words.)

An example with actual values is shown below:

1 : BIRTHDAY : 4
2 : BJORNE   : 1
3 : HAPPY    : 4
4 : TO       : 4
5 : YOU      : 3

Refer to the expected output files for longer examples on the expected formatting.

countLetters()

Input: (1) An array of 26 unsigned integers (2) A vector of strings

Output: None

Task: Count the number of occurrences of each letter present in all words. Each position of the array corresponds to each letter as ordered by the English alphabet. Upon completion, the array will hold the counts of each letter and the vector of strings will remain unchanged.

printLetterCounts()

Input: An array of 26 unsigned integers

Output: None

Task: For each letter, print out the letter and its corresponding count. Format the output as follows:

A : #C
B : #C
...
Y : #C
Z : #C

Notice how there are two columns separated by :. We want the : aligned in every row and the values aligned in each column. The columns correspond to the following values:

  1. A – The letter
  2. #C – The corresponding count of the letter. Right align all values. Allocate enough space for the length of the largest number. (Assume there will be at most 109 unique words.)

An example with actual values is shown below:

A :  8
B :  5
C :  0
D :  4
E :  1
F :  0
G :  0
H :  8
I :  4
J :  1
K :  0
L :  0
M :  0
N :  1
O :  8
P :  8
Q :  0
R :  5
S :  0
T :  8
U :  3
V :  0
W :  0
X :  0
Y : 11
Z :  0

Refer to the expected output files for longer examples on the expected formatting.

printMaxMinWord()

Input: (1) A vector of strings (2) A vector of unsigned integers

Output: None

Task: Print out the two words that occur least often and most often. If there is more than one word that occurs the same number of times, print the one that comes first alphabetically. Upon completion, both input vectors will remain unchanged. Print out the following pieces of information:

  1. The word
  2. The number of occurrences
  3. The frequency of appearance as a percentage to 3 decimal places

Format the output as follows:

Least Frequent Word: ABCDEF #C (#P%)
Most Frequent Word:  ABCDEF #C (#P%)

Notice how there are three columns of values. The columns correspond to the following values:

  1. ABCEDF – The word. Left align all values. Allocate enough space for the longer of the two words.
  2. #C – The corresponding count of the word. Right align all values. Allocate enough space for the length of the larger number. (Assume there will be at most 109 unique words.)
  3. #P – The frequency of the word. Right align all values. Print to three decimal places.

An example with actual values is shown below:

Least Frequent Word: BJORNE   1 (  6.250%)
Most Frequent Word:  BIRTHDAY 4 ( 25.000%)

Refer to the expected output files for longer examples on the expected formatting.

printMaxMinLetter()

Input: An array of 26 unsigned integers

Output: None

Task: Print out the two letters that occur least often and most often. If there is more than one letter that occurs the same number of times, print the one that comes first alphabetically. Upon completion, the input array will remain unchanged. Print out the following pieces of information:

  1. The letter
  2. The number of occurrences
  3. The frequency of appearance as a percentage to 3 decimal places

Format the output as follows:

Least Frequent Letter: A #C (#P%)
Most Frequent Letter:  Z #C (#P%)

Notice how there are three columns of values. The columns correspond to the following values:

  1. A – The letter.
  2. #C – The corresponding count of the letter. Right align all values. Allocate enough space for the length of the larger number. (Assume there will be at most 109 occurrences.)
  3. #P – The frequency of the letter. Right align all values. Print to three decimal places.

An example with actual values is shown below:

Least Frequent Letter: C  0 (  0.000%)
Most Frequent Letter:  Y 11 ( 14.667%)

Refer to the expected output files for longer examples on the expected formatting.

Functional Requirements

  • You may not make use of the standard library functions sort(), find(), any_of() or anything else from #include <algorithm>. You must implement your own sorting and searching functions.
  • DO NOT use global variables.
  • You must use parameters properly, either pass-by-value or pass-by-reference.
  • Do not use any global variables. You must use parameters properly.
  • Mark parameters as const appropriately if the function is not modifying the parameter value.
  • For this assignment, the output must match the example outputs exactly.
  • For this assignment, only submit your functions.h and functions.cpp files. Do not include main.cppCMakeLists.txt, or any of the other input/output files.

Calculate the price
Make an order in advance and get the best price
Pages (550 words)
$0.00
*Price with a welcome 15% discount applied.
Pro tip: If you want to save more money and pay the lowest price, you need to set a more extended deadline.
We know how difficult it is to be a student these days. That's why our prices are one of the most affordable on the market, and there are no hidden fees.

Instead, we offer bonuses, discounts, and free services to make your experience outstanding.
How it works
Receive a 100% original paper that will pass Turnitin from a top essay writing service
step 1
Upload your instructions
Fill out the order form and provide paper details. You can even attach screenshots or add additional instructions later. If something is not clear or missing, the writer will contact you for clarification.
Pro service tips
How to get the most out of your experience with Homework Writing Services
One writer throughout the entire course
If you like the writer, you can hire them again. Just copy & paste their ID on the order form ("Preferred Writer's ID" field). This way, your vocabulary will be uniform, and the writer will be aware of your needs.
The same paper from different writers
You can order essay or any other work from two different writers to choose the best one or give another version to a friend. This can be done through the add-on "Same paper from another writer."
Copy of sources used by the writer
Our college essay writers work with ScienceDirect and other databases. They can send you articles or materials used in PDF or through screenshots. Just tick the "Copy of sources" field on the order form.
Testimonials
See why 20k+ students have chosen us as their sole writing assistance provider
Check out the latest reviews and opinions submitted by real customers worldwide and make an informed decision.
Business
Thank you for following all instructions. Good piece
Customer 463337, March 1st, 2023
Education
excellent
Customer 463813, March 10th, 2023
Business and administrative studies
Great effort.
Customer 452615, May 19th, 2022
Military
Good job
Customer 456821, January 11th, 2023
Ecology
Good
Customer 453413, April 19th, 2020
Health Care
Met expectations. Thank you.
Customer 454755, June 30th, 2020
Technology
Great writer
Customer 454057, May 20th, 2020
Statistics
Super professional and highly qualified. Excellent customer service.
Customer 462485, May 29th, 2022
Medicine
Properly format papers in the instructed style and always use Grammarly.
Customer 458101, April 10th, 2022
Business and administrative studies
Outstanding work!!
Customer 460073, August 4th, 2022
Business and administrative studies
Outstanding!
Customer 456823, April 2nd, 2022
Aviation
Paper was received on time but the revision was late. This was worth the wait as the revision helped me better understand the topic more. Thanks!
Customer 454145, April 12th, 2020
11,595
Customer reviews in total
96%
Current satisfaction rate
3 pages
Average paper length
37%
Customers referred by a friend
OUR GIFT TO YOU
15% OFF your first order
Use a coupon FIRST15 and enjoy expert help with any task at the most affordable price.
Claim my 15% OFF Order in Chat