Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For this assignment we will write a C++ program that serves as a very rudimentary word processor. Our program will read input and perform some

For this assignment we will write a C++ program that serves as a very rudimentary word

processor.

Our program will read input and perform some transformations, and generate output.

For this assignment, we use the following definitions:

A word is a sequence of non-whitespace characters.

An empty line is a line with no characters in it at all.

A blank line is a line containing only one or more whitespace characters.

The line length is the number of characters in each line that was output.

A paragraph is a collection of lines. There are no blank lines or empty lines in a

paragraph.

An indent is spaces at the very beginning of the first line of a paragraph.

The program reads lines of input and prints out paragraphs.

The line length for each output line may be specified as a command line argument. If no

command line argument for the line length is specified, the program should use a line length of

40.

The number of spaces to indent each paragraph may be specified as a command line

argument. If no command line argument for indent is specified, the program should use an

indent of 8.

Words in the output are separated by a single whitespace character. So, for example, the input

Hello world should appear as Hello world in the output.

One or more consecutive empty or blank lines, or the end of file, should be interpreted as the

end of a paragraph. Several consecutive empty or blank lines should cause a single empty line

to be generated on output.

The output must be filled out to a length less than or equal to the line length. This may involve

combining several lines of input into a single line of output.

For example, assume we have an input file like so:

1

This is

my favorite class.

Of all time!! Really, I swear!

If the indent is 5, and the line length is 80, then the output will be:

This is my favorite class.

Of all time! Really, I swear.

Notice that we combined the first two lines of input into a single line of output, we deleted the

multiple spaces between This and is, we indented 5 spaces, and we combined multiple blank

lines into a single line between paragraphs.

Whitespace at the beginning and end of a line of input should be ignored.

Note that the length of the output line should not exceed the line length. The only exception to

this rule is if there is only a single word on the output line.

For example, suppose we have an indent value of 10, a line length of 15, and input as follows:

Several

of us just loooooooooooooooooove C++!

The output would be:

Several

of us just

loooooooooooooooooove

C++!

Observe that we ignored the leading spaces in the first line of input. Note also that the first and

third lines of output exceed the line length of 15; because there is only one word in the output

line, this is acceptable. The second line of output does not have loooooooooooooooooove on

the line because adding it would cause the output line to exceed the line length.

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_2

Step: 3

blur-text-image_3

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

Intelligent Information And Database Systems Asian Conference Aciids 2012 Kaohsiung Taiwan March 2012 Proceedings Part 2 Lnai 7197

Authors: Jeng-Shyang Pan ,Shyi-Ming Chen ,Ngoc-Thanh Nguyen

2012th Edition

3642284892, 978-3642284892

More Books

Students also viewed these Databases questions

Question

8-6 Who poses the biggest security threat: insiders or outsiders?

Answered: 1 week ago