->Homepage
->Schedule
->Courses
-->CS182
-->Tentative Schedule
-->Objectives
-->Quiz 1
-->Lab 1
-->Lab 2
-->Lab 3
-->Lab 4
-->Lab 5
-->Lab 6
-->Lab 7
-->Project
-->CS183
-->CS285
->Course Policies
->Electronic Submission
->Documentation Standards
->Old Exams
->C++ Examples
->MSVC++ Info
->Software
->Support Forum
->Unix Info
->Nature Photos

[Home]
[Rich][Home][Rich]
[Author]
CS182 -- Lab 8: Text Formatting

Winter 2003-2004

--
Overview

The purpose of this project is to apply skills develop throughout the course to a more complex task than typical one week lab assignments.

Procedures

This assignment is worth three times as much as a standard lab.

Write a program that will read in a text file (user specified) and format the text so that it is full justified. The user should be able to specify the number of characters per line (between 10 and 120). The results should be written to an output file (user specified).

In the input file:

  • Individual "words" are signified by at least one whitespace character before and after the "word".
  • A "word" may contain punctuation marks.
  • Paragraph breaks are signified by at least one blank line between text.

In the output file:

  • The last character of the final "word" in each line should be located in the nth column, where n is the number of characters per line as specified by the user.
    Note: This does not apply to the last "word" of a paragraph.
  • All "words" that do not end with a period, semicolon, or colon (. ; :) should have at least one space after them. (Unless they are the last "word" on the line.)
  • All "words" that end with a period, semicolon, or colon (. ; :) should have at least two spaces after them. (Unless they are the last "word" on the line.)
  • All paragraphs should be separated by one blank line.
  • All words in the last line of each paragraph should have the minimum spacing (as specified above) after them.

For example, if the following text were given to your program, and the line length were specified to be 40 characters:

While I have not specified exactly how you should do the
justification, part of your   grade
will be based on how visually pleasing your results are.

As a general
  rule, you should strive to reduce the total number
of spaces required and the maximum number of spaces
between two words as much as   possible.

your program should produce an output file that is similar to the following:

While I  have not specified  exactly how
you should do the justification, part of
your grade will be based on how visually
pleasing your results are.

As a general  rule, you should strive to
reduce   the  total   number  of  spaces
required  and  the  maximum   number  of
spaces  between  two words  as  much  as
possible.

In addition, the following statistics should be appended to a log file:

  • The names of the input/output files
  • The number of characters per line
  • Number of paragraphs
  • Number of words
  • Number of spaces required
  • Maximum number of spaces between two words
  • Number of lines in the original file
  • Number of lines in the formatted file
Just for Fun

Although not required, you may choose to enhance your program with additional features. For example, you could add an option to select the number of characters to indent each paragraph or add a graphical user interface. Let your imagination run wild, but be sure to do the minimum requirements before embarking on any significant enhancements.

Weekly logs (due 11:00pm, the day prior to weeks 9 and 10 labs)

You should submit activity logs each week to indicate your activity and progress on this assignment.

Program Demonstration (last day of class)

You will be required to demonstrate your program at the beginning of the last day of class. Programs that are not ready to be demonstrated at the beginning of class will be considered late. In order to demonstrate your program, you will be given a set of input files and asked to run your program on them with specified line lengths. The output files and the log file should be zipped and submited (choose OTHER for assignment type) before the end of class.

Lab report (due 11:00pm, the day prior to the last lecture)

Here is a template file to use as a starting point for this report.

The lab report should be in your own words and self-contained. By self-contained I mean that it should be possible for someone to understand what you did and why without seeing anything other than your report. Your report should include:

  • Purpose (educational objectives)
  • Problem Statement
  • Procedure (the steps you used to design your program, reasons for your design decisions, etc.)
  • Discussion (do not include sample program output since I will already have your zipped file with samples, problems you encountered (and how they were overcome), etc.)
  • Conclusions (what you learned, suggestions of how the assignment could be improved, things you would have done differently, etc.)
  • A summary of your activity log indicating how much time you spent on each phase of the assignment. Please report the time in the following categories:
    • Design
    • Coding
    • Debug (before you think it's working)
    • Test (after you think it's working)
    • Documentation
    • Other
  • Documented source code for your program.

As with any report you submit, correct spelling and grammar are required. In addition, your report should be submitted electronically following the Electronic submission guidelines. (You may wish to consult the XML help video and/or sample report before submitting your report.) Be sure to keep copies of all your files, in case something gets lost. It may be wise to keep a diskette backup as well.

Your grade will depend on quality of design, clarity of code and documentation, as well as whether your program produces the correct results. If you have any questions, consult your instructor.

Acknowledgment

This laboratory assignment was developed by Dr. Chris Taylor.

Last Updated: Thursday, 01-Jan-2015 14:33:26 EST