600.108 Intro Programming Lab Week 6

PROBLEM STATEMENT ------------------------------------------------------------

Write a program which will convert a plain text file to a randomly

formatted html file. The random formats will consist of centering (or

not), font colors and heading styles. Most html formatting

instructions, called tags, follow a general pattern of being enclosed

in angle brackets to begin, as in , and using a slash to end,

as in . In "proper" html, when multiple formats are applied

to a line, their tags should be properly nested.

Centering a line is accomplished by putting the html tag
before the line starts, and following the line with
to end

the centering format. Colors can be expressed as a six character

string preceded by a #. Every two characters in the string are the

same, the first pair representing the amount of Red, second for Green

and third is Blue (RGB values). Possible values for the characters

are the digits 0, 3, 6, 9 and the letters C and F. In order to set

the font of some text to a particular color in an html document, use
before the text and after the text.
Lastly, there are 6 levels of headings in html. Each one is

designated with a tag pair , where the # is a digit from 1

to 6.

Your program should prompt the user for the name of an input plain

text file and then create an output file whose name is the same as the

input file name, with ".html" added to the end. In this output file,
every line of the original file should be repeated, with a random

color and heading style formatting it, either centered or not. Using

this problem description as the sample input file, a sample output

file is posted at
. In order to
view the html itself (what your program must create), choose the view
file source menu option of your web browser after displaying this

output file.

Phase I: Write a method that takes a string, chooses a random number

between 1 and 6 and given this number, #, returns string For

example, if the parameter value is "hello" and the number chosen is 4,

the method returns "

hello

". Write a main method that calls

this method with 3 different strings and displays the result on the
screen for testing.

>>> Switch driver/nagivator roles <<<

Phase II: Write a method that takes a string, and randomly decides

whether to return the original string without any changes, or to

return
string
instead. Add some code to main to test

this out.

>>> Switch driver/nagivator roles <<<

Phase III: Write a method that takes a string, and chooses three

characters from the set {0,3,6,9,C,F} randomly. It then transforms

string into string where x, y, and z were

the three randomly chosen characters, returning the result. Add some

code to main to test this method.

>>> Switch driver/nagivator roles <<<

Phase IV: Write a program that prompts a user for a filename, then

reads the file, transforms each line in all the above-described ways,

then writes it to another file, with the filename of

"inputfilename"+".html", where inputfilename was the given input file
name.

**************************************************

MAKE SURE YOU DELETE YOUR FILES OFF THE LAB COMPUTER WHEN DONE!!!

FAILURE TO DO SO IS AN ETHICS VIOLATION!

**************************************************