You have seen how to perform right justification upon extraction from a line of
ID: 3829236 • Letter: Y
Question
You have seen how to perform right justification upon extraction from a line of data. Your task will be to create the flow chart for a left justification of a line of code extracted from a larger line of code. What you will need to consider: Transfer of bytes is already in order. The bytes transferred from input to output may be fewer than the size of the output. Thus, you will need to fill with spaces. How can you handle multiple words separated by spaces? The test program will be almost the same as for right justification. Obviously there will be some minor changes to accommodate the specific needs of the subroutine. Create and turn in flow charts for the extract and left justify subroutine and a test program that will verify that your subroutine works. Code is not required, although it would be accepted should you choose to write it.Explanation / Answer
The algorithm for left justification is as follows:
1. Accept the bytes of data.
2.If the beginning of a line has spaces ignore the bytes until a character appears.
3.Push the characters into a queue until space is encountered.
4.When a space in encountered pop the elements from the queue in FIFO order in order to complete the word.
5.Insert a space after that and repeat steps 2 to 4 till the end character in encounter.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.