Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Program description Sample input file : Sample output file : Write a simple text-formatting program that reads a text file and produces another text file

Program description image text in transcribed
Sample input file :
image text in transcribed
Sample output file :
image text in transcribed
Write a simple text-formatting program that reads a text file and produces another text file in which blank lines are removed, multiple blanks are replaced with a single blank, and no lines are longer than some given length. Put as many words as possible on the same line. You will have to break some lines of the given file, but do not break any words or put punctuation marks at the beginning of a new line A sample run to format a text file Lincoln.txt to a new text file Formatted.txt is: Please enter the name of the input file containing unformatted text: Lincoln.txt Please enter the name of the output file to contain formatted text Formatted.txt Please enter maximum length of line (1 -72) 40 Press any key to continue Note You need to input the given length (between 1 and 72) from keyboard. Your program should check if you can successfully open files for read and write. Download the test input file: Lincoln.txt and compare you output file with the correct output file Formatted.txt, to verify your program. Hint Read from the input file word by word Keep track of the number of characters, which is used to decide when to make a new line

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

Information Modeling And Relational Databases

Authors: Terry Halpin, Tony Morgan

2nd Edition

0123735688, 978-0123735683

More Books

Students also viewed these Databases questions