Program 3
HTML File Processing
due Thursday, March 9th by the start of lab
Lab Partners
Everyone is encouraged to work with one lab partner (who is in
the same lab section as yourself) on this assignment.
If you do work with a partner, submit one solution with both of your
names on it. Also, please look at the
class
collaboration policy so that you know what is and what isn't
allowed.
General Overview
Write a Java program that prompts the user for the name
of an html file that is located in the same directory as the
Java project. The program should print each html tag that occurs
in the file in alphabetical and state how many times the tag occurred.
Purpose
The purpose of this assignment is to give you experience with
file input and sorting.
sample.html file
<html>
<head>
<title>Sample File</title>
</head>
<body>
<ol>
<li>Item 1</li>
<li>Item 2</li>
</ol>
</body>
</html>
Sample Run
Please enter the name of a file: sample.html
HTML tag analysis for sample.html
tag count
--- -----
body 1
head 1
html 1
li 2
ol 1
title 1
Requirements and Grading
- 20 points. The program finds all html tags correctly for
any html file. You may assume that all html tags occur in
lowercase letters.
- 10 points. The program counts the number of occurrences
of all html tags correctly for any html file.
- 10 points. The program prints the html tags in alphabetical order
for any html file.
- 10 points. The output format matches the format of the sample
run above exactly.
- 10 points. The solution is required to define and use a class
named Tag that stores both the name (a String) and
count (an integer) of a given tag. A given html tag
(such as li) should only appear in one instance of the
Tag class.
- 10 points. While the html file is being read, the html tags
(along with their counts) are
maintained in sorted order. An appropriate, efficient sorting
technique should be used to accomplish this.
- 5 points. The solution is well commented.
- 5 points. If the user enters a file that does not exist, the
program should prompt the user for a new file. This should be repeated
until the user enters a file that exists.
- 10 points. The solution uses object oriented programming
correctly.
- 10 points. The solution contains high quality code.
What to Submit
E-mail your code to your lab TA in one message.
The subject of the message
should be: CS221-xx program3 your-names.
The xx is the number of your lab section.
Your lab TA must receive your e-mail by the start of your lab period
on the date on which the assignment is due. Otherwise there
will be a 25 point per day late penalty.