Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello C++ programmer , i need help with this assignment. this code must use getline() and vector words , please don not use stringstream() instead

Hello C++ programmer, i need help with this assignment. this code must use getline() and vectorwords, please don not use stringstream() instead you can use

must consider adjustment inplementation , and also helpful hints are given for the for loop condition if you read the details you will see that .. . i need the solution in 24 hours.......ALL THE DETAILS ARE GIVEN IN THE ATTACHED PICTURE ...PLEASE READ THE DETAILS...

PLEASE READ THE GIVEN DETAILS BEFORE YOU DO THE CODE.....IT WILL BE HELPFUL TO UNDERSATND THE MISSION OF THIS CODE. ADVANCE THANKS. image text in transcribedimage text in transcribedimage text in transcribed

A Simple Paragraph Justifier The mission of this assignment is to realize a simple paragraph justifier. As shown in my coding demonstration, your program will keep reading lines of text image using getline. After reading a paragraph, it adjusts all the lines into an instructed width, so that it can show the words evenly spread out and fit in a straight edge at both margins (similar to "align full option in a Microsoft word document) This can be relatively easily done as we are dealing with a mono-space font set (not a proportional font set) shown on a command-line-type console. As an example consider a line containing 5 words and 30 characters altogether. If this line needs to be justified into a 40-character width, the remaining10 spaces needs to be spread out between the words. Assume that the first word of the next line has more than 9 characters, that is, the word in the next line cannot be placed in the tail of this line so as to consume the extra spaces. In this case, 2 spaces are placed between the first 4 words, followed by 4 spaces prior to the last word (tail adjustment), or 3 spaces are placed between the first 4 words followed by a space prior to the last word (even adjustment) The requirements of this assignment are 1. program keeps reading lines of text until reading an empty line program then reads a width for the read paragraph 3. program then justifies the paragraph based on tail adjustment 4 program then shows the result in a bounding box 5. program allows to adjust the paragraph by going back to 2 6. program ends when it reads 0 as a new width Restriction: Do not use stringstream. Instead parse each line read into words. A word should be defined as a sequence of non-white space characters delimited by white-space before and after it. And, remember that getline does not read the new-line, So here is a hint: Use the length of the line read to determine when your parse has reached the end of the line. Also the functionality provided will be helpful Hint For the solution of this problem you will have to read all of your words into a vector of strings Extra points (2 points) will be considered for even adjustment implementation Here is a hint to realize this mission lines of words, say vector words, is a straightforward conversion as implemented in the previous assignment and posted lecture example. Now, user types some width for justification. Let this width be W. The mission is to fill i-words in one line of this W. Note i> 0, i.e., every line must have at least one word. The logic will be 1. let{wi, w2, . wi be a collection of words. Then, w1.length w2.1ength) .. wi.length) is the total length of this collection 2. since we need at least one space between these i words, we need i-l spaces at least, and therefore, we need Wrmin = w1 . length () + w2. length () + +wi.length) ( 1) characters, which must be less than or equal to W 3. your first loop must identify this i and Wmin by going through vector words you created in the second loop, you simply create a line by adding w1 through wi-1 by placing a space between the two consecutive words A Simple Paragraph Justifier The mission of this assignment is to realize a simple paragraph justifier. As shown in my coding demonstration, your program will keep reading lines of text image using getline. After reading a paragraph, it adjusts all the lines into an instructed width, so that it can show the words evenly spread out and fit in a straight edge at both margins (similar to "align full option in a Microsoft word document) This can be relatively easily done as we are dealing with a mono-space font set (not a proportional font set) shown on a command-line-type console. As an example consider a line containing 5 words and 30 characters altogether. If this line needs to be justified into a 40-character width, the remaining10 spaces needs to be spread out between the words. Assume that the first word of the next line has more than 9 characters, that is, the word in the next line cannot be placed in the tail of this line so as to consume the extra spaces. In this case, 2 spaces are placed between the first 4 words, followed by 4 spaces prior to the last word (tail adjustment), or 3 spaces are placed between the first 4 words followed by a space prior to the last word (even adjustment) The requirements of this assignment are 1. program keeps reading lines of text until reading an empty line program then reads a width for the read paragraph 3. program then justifies the paragraph based on tail adjustment 4 program then shows the result in a bounding box 5. program allows to adjust the paragraph by going back to 2 6. program ends when it reads 0 as a new width Restriction: Do not use stringstream. Instead parse each line read into words. A word should be defined as a sequence of non-white space characters delimited by white-space before and after it. And, remember that getline does not read the new-line, So here is a hint: Use the length of the line read to determine when your parse has reached the end of the line. Also the functionality provided will be helpful Hint For the solution of this problem you will have to read all of your words into a vector of strings Extra points (2 points) will be considered for even adjustment implementation Here is a hint to realize this mission lines of words, say vector words, is a straightforward conversion as implemented in the previous assignment and posted lecture example. Now, user types some width for justification. Let this width be W. The mission is to fill i-words in one line of this W. Note i> 0, i.e., every line must have at least one word. The logic will be 1. let{wi, w2, . wi be a collection of words. Then, w1.length w2.1ength) .. wi.length) is the total length of this collection 2. since we need at least one space between these i words, we need i-l spaces at least, and therefore, we need Wrmin = w1 . length () + w2. length () + +wi.length) ( 1) characters, which must be less than or equal to W 3. your first loop must identify this i and Wmin by going through vector words you created in the second loop, you simply create a line by adding w1 through wi-1 by placing a space between the two consecutive words

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

Data Infrastructure For Medical Research In Databases

Authors: Thomas Heinis ,Anastasia Ailamaki

1st Edition

1680833480, 978-1680833485

More Books

Students also viewed these Databases questions

Question

How does IP spoofing support Internet crime?

Answered: 1 week ago

Question

Determine the orientation (0 Answered: 1 week ago

Answered: 1 week ago