Problem Statement 1

Implement the function justify in the file justify.cpp to perform left and right justification on a text input of type string. The justified text is a vector of strings. The assumptions for the input text are as follows:

  • The input text consists only of alphabets (lower and upper case), blank spaces (), and two punctuation marks (periods (.), and commas (,)).
  • Every word in a sentence in the input text is separated by a single blank space.
  • The punctuation marks immediately follow the last character of the preceding word, and a single space is present between a punctuation mark and the following word.
  • There are no new line characters in the input string.

We will perform a very primitive form of justification in this assignment using the following rules:

  • Every line in the justified text must have at least width 2 characters, with the exception of the last line, which may have fewer characters.
  • Every line in the justified text must have at most width characters, with the exception of lines that terminate with a punctuation mark (period or comma). In such cases, the line may have width+1 characters to accommodate the trailing punctuation mark.
  • Every line in the justified text must start with an alphabet (word). The first character in a line cannot be a punctuation mark or space.
  • If a word needs to be split across lines in order to follow the above rules, a hyphen (-) character must be inserted after the first part of the word. The hyphen character counts toward the total number of characters in a line.

Problem Statement 2

Requirements: Write a C++ program to that will use a pointer list_ptr to dynamically allocate memory for a list of integer values. The program will search for the largest and smallest values within the list and use the pointers list_small and list_large to store the locations of the smallest and largest values respectively. The program will prompt the user to enter the number of elements in the list and then ask the user to input the values one at a time using the keyboard.

The dynamic memory allocated by the code (using new) should be returned to the system at the end of the program (using delete).

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.