08 Jun CS210 Programming Assignment 3 Word Processing
Question
CS210 Programming Assignment 3
A common task in word processing is to reformat input text into a more structured format to match
English grammar. For example, there should be a single space following a comma, two spaces following
a period, and the first word in each sentence should be capitalized. Furthermore, text can be aligned
either left, right, center, or fully justified to look “better” when scanned down a page.
This assignment is to write a program that takes command line arguments for input file, output file, and
formatting options then produce the output file based on formatting rules.
Part 1 – Spacing and Capitalization
All input text should be processed by the following rules:
? There should be exactly one space between each word.
? There should be exactly one space after a comma (,) before the next word. Do not insert spaces
unless there is an additional word on the same line.
? The word “I” (capital i), should always be capitalized.
? There should be exactly two spaces after a period (.), question mark (?), or exclamation point (!)
before the next word. Do not insert spaces unless there is an additional word on the same line.
? The first word in each sentence should be capitalized. This includes the first word in each
paragraph and the first word after each period, question mark, or exclamation point.
Example input:
the quick red fox jumped over the brown lazy dog.the quick, red fox
jumped over the brown ,lazy dog. should i like dogs? yes, I like dogs
a lot!
Issues:
the quick __red fox jumped over the brown lazy dog.the quick, red fox
jumped over the brown__,lazy dog._should i like dogs?_yes, I like dogs
a lot!
Expected output:
The quick red fox jumped over the brown lazy dog. The quick, red fox
jumped over the brown, lazy dog. Should I like dogs? Yes, I like
dogs a lot!
Part 2 – Justification
Text can also be left, right, center, or fully justified. Most text that you read is already left justified.
Input text:
The quick red fox jumped over
the brown lazy dog. The quick,
red fox jumped over the brown,
lazy dog. Should I like dogs?
Yes, I like dogs a lot!
Output text, justified to 33 columns (your code will justify to 72 columns)
The quick red fox jumped over
the brown lazy dog. The quick,
red fox jumped over the brown,
lazy dog. Should I like dogs?
Yes, I like dogs a lot!
The quick red fox jumped over
the brown lazy dog. The quick,
red fox jumped over the brown,
lazy dog. Should I like dogs?
Yes, I like dogs a lot!
Left justified text Right justified text
The quick red fox jumped over
the brown lazy dog. The quick,
red fox jumped over the brown,
lazy dog. Should I like dogs?
Yes, I like dogs a lot!
The quick red fox jumped over
the brown lazy dog. The quick,
red fox jumped over the brown,
lazy dog. Should I like dogs?
Yes, I like dogs a lot!
Center justified text Fully justified text
(see note about the last line)
Note that you should not change line breaking or reduce spacing between words while performing
justification. However, you are permitted to add or remove spaces at the start of each line and add
additional spaces between words (for full justification). Your program should take a third argument to
specify justification.
? “-left” : The first word on each line starts at column 0.
? “-right”: The last word on each line ends at column 72.
? “-center”: There are (approximately) an equal number of spaces at the beginning and end of
each line.
? “-full”: The first word starts at column 0, the last ends at column 72, and intra-word spacing is
approximately equal. Note that modern word processors don’t apply this to the last line in each
paragraph (as above). However, this is not a requirement for your program.
Example command line usage:
java Program3 input.txt output.txt –center
Grading Criteria:
Capitalization is correct 15
Spacing is correct after punctuation 15
Extraneous spacing is removed 15
Left justification works 10
Right justification works 10
Center justification works 15
Full justification works +10 (bonus)
Code is readable and well structured 10
Error handling 10
Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of HIGH QUALITY & PLAGIARISM FREE. To make an Order you only need to click Ask A Question and we will direct you to our Order Page at WriteDemy. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.
Fill in all the assignment paper details that are required in the order form with the standard information being the page count, deadline, academic level and type of paper. It is advisable to have this information at hand so that you can quickly fill in the necessary information needed in the form for the essay writer to be immediately assigned to your writing project. Make payment for the custom essay order to enable us to assign a suitable writer to your order. Payments are made through Paypal on a secured billing page. Finally, sit back and relax.
About Writedemy
We are a professional paper writing website. If you have searched a question and bumped into our website just know you are in the right place to get help in your coursework. We offer HIGH QUALITY & PLAGIARISM FREE Papers.
How It Works
To make an Order you only need to click on “Order Now” and we will direct you to our Order Page. Fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.
Are there Discounts?
All new clients are eligible for 20% off in their first Order. Our payment method is safe and secure.
