Computer Science 202
Programming Assignment 3
Assigned: February 20, 1998
Due: March 6, 1998
I'm sure that all of you have used the World-Wide Web. Web pages are written
in a language called HTML (Hyper Text Markup Language). Your programming
assignment lets you work with simple HTML files. Display a main menu of
options from which the user may select again and again in any order. If the
user doesn't select a correct option, make the user select again.
The options are as follows:
1. Display how a given HTML file would look in some form of browser. The
HTML file will consist of zero or more ordered and/or unordered lists. When
this option is selected, ask the user for two file names: an input file
containing the HTML commands, and an output file where the formatted text will
be stored. The
and
tags are used to open and close ordered
(numbered) lists, and the tags are used to open and close
unordered lists.
2. Given an indented input file, produce the HTML file
corresponding to the file. When this option is selected, ask the user
for two file names: an input file, and an output file where the HTML output
will be stored.
Samples of input and output files for each option are given below.
Part 1:
Sample HTML file:
- Mathematics
- Computer Science
- Students
- Current
- Inactive
- Alumni
- Staff
- Faculty
- Physics
- English
- Foreign Language
- Computer Engineering
- Electrical Engineering
- Geology
Output:
1. Computer Engineering
2. Computer Science
* Faculty
* Staff
* Students
1. Alumni
2. Current
3. Inactive
3. Electrical Engineering
4. English
5. Foreign Language
6. Mathematics
7. Physics
If the input file is not valid HTML (i.e., a list is not terminated
correctly, there are too many tags, or tags don't match up properly),
give the user an error message indicating which line of the file caused the
problem.
Part 2:
Given an indented text file, produce an HTML file which will give
a similar effect. The first line of the file contains a number indicating
the number of spaces in an indentation unit.
Sample Input File:
3
Data Structures
Algorithms
Theory of Computation
Upper Bounds
Time
Space
Lower Bounds
Output:
- Algorithms
- Data Structures
- Theory of Computation
- Lower Bounds
- Upper Bounds
By now, you may have noticed that this assignment looks very similar to your
first assignment this semester. It is. What is the difference? The
difference is that in your output files, the order of the 's is changed.
The 's corresponding to each or must be placed in the output
file in alphabetical order.
You can assume at most 3 different indentation levels, and there will be at
most one list at each indentation level, as in the sample files. For extra
credit (20 points), handle an arbitrary number of levels of nesting.
Sample files for extra credit:
Part 1:
Sample HTML file:
- Mathematics
- Graduate Students
- Seniors
- Sophomores
- Freshmen
- Juniors
- Computer Science
- Students
- Current
- Inactive
- Alumni
- Staff
- Faculty
- Physics
- English
- Foreign Language
- Computer Engineering
- Electrical Engineering
- Geology
Output:
1. Computer Engineering
2. Computer Science
* Faculty
* Staff
* Students
1. Alumni
2. Current
3. Inactive
3. Electrical Engineering
4. English
5. Foreign Language
6. Mathematics
* Freshmen
* Graduate Students
* Juniors
* Seniors
* Sophomores
7. Physics
If the input file is not valid HTML (i.e., a list is not terminated
correctly, there are too many
tags, or tags don't match up properly),
give the user an error message indicating which line of the file caused the
problem.
Part 2:
Given an indented text file, produce an HTML file which will give
a similar effect. The first line of the file contains a number indicating
the number of spaces in an indentation unit.
Sample Input File:
3
Data Structures
Homogeneous
Heterogeneous
Arrays
Linked Lists
Algorithms
Sorting
Searching
Graph
Theory of Computation
Upper Bounds
Time
Space
Lower Bounds
Output:
- Algorithms
- Data Structures
- Arrays
- Heterogeneous
- Homogeneous
- Linked Lists
- Theory of Computation
- Lower Bounds
- Upper Bounds