Question: Please do this program in C++ and make sure that you do the program in the main, i cant have any other functions out of

 Please do this program in C++ and make sure that you

do the program in the main, i cant have any other functions

Please do this program in C++ and make sure that you do the program in the main, i cant have any other functions out of the main. The whole code has to be in the main. Make as simple as possible.

Algorithm/Pseudo-code for Exercise 1 1. This exercise requires you to compress several consecutive "whitespaces" into a single space. A whitespace can be a spacea tab '"\f, or a newline n' and/or . So it is convenient to define a function to check if a character is a whitespace or not. For example, define the following function to accomplish it. 2. The beginning whitespaces, if any, need to be removed. 3. Read the input character one at a time, call IsWhiteSpace0 to check if it is a whitespace. If not, write the character to the output. If yes, go to 3.a. Repeat this step until all characters are read. a. You would need a bool flag to help you identify if the current whitespace is the first one between two words. If so, writes a space to the output string; if not, do not write anything. Reset this flag if the next character is not a whitespace. Go back to step 3 if more characters are to be read in the string. Special case needs to be handled for the very beginning whitespace of the input string. Use a bool variable to help you. b. c. bool aticstRJAR= false; // Used for the compressing consecutive whitesnaces bool iinitial-true; I/ Used for removing the beginning whitespaces // Read in all characters and change all characters to lowercase and compress // nk consecutive whitespaces to a single bla // Skip the beginning whitespaces continue /I compress all consecutive whitespace into one blank add a space to the new string else // We have already got the first non-whitespace character // So there are no more beginning whitespaces isiana, = false; aticstRARk = false add the toloneRcharacter) to the new string Algorithm/Pseudo-code for Exercise 1 1. This exercise requires you to compress several consecutive "whitespaces" into a single space. A whitespace can be a spacea tab '"\f, or a newline n' and/or . So it is convenient to define a function to check if a character is a whitespace or not. For example, define the following function to accomplish it. 2. The beginning whitespaces, if any, need to be removed. 3. Read the input character one at a time, call IsWhiteSpace0 to check if it is a whitespace. If not, write the character to the output. If yes, go to 3.a. Repeat this step until all characters are read. a. You would need a bool flag to help you identify if the current whitespace is the first one between two words. If so, writes a space to the output string; if not, do not write anything. Reset this flag if the next character is not a whitespace. Go back to step 3 if more characters are to be read in the string. Special case needs to be handled for the very beginning whitespace of the input string. Use a bool variable to help you. b. c. bool aticstRJAR= false; // Used for the compressing consecutive whitesnaces bool iinitial-true; I/ Used for removing the beginning whitespaces // Read in all characters and change all characters to lowercase and compress // nk consecutive whitespaces to a single bla // Skip the beginning whitespaces continue /I compress all consecutive whitespace into one blank add a space to the new string else // We have already got the first non-whitespace character // So there are no more beginning whitespaces isiana, = false; aticstRARk = false add the toloneRcharacter) to the new string

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!