Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please read carefully and solve in Java accordingly to the instruction, this is a beginner assignment in a beginner course that just finished learning about

image text in transcribedimage text in transcribedimage text in transcribed

Please read carefully and solve in Java accordingly to the instruction, this is a beginner assignment in a beginner course that just finished learning about string so please don't use any import or function that a beginner would have a hard time to understand.

description In this assignment, you'll write a Java program which asks the user to enter the name of a plain text file. The program reads the file and then outputs an html version according to the guidelines provided. The purpose of the assignment is to provide some practice reading and writing files as well as reinforcing what you've learned about handling Strings If you're unfamiliar with the basics of HTML or need a refresher, you can learn more at w3schools. file names The user should enter the name of an input file which ends ".txt". The output file should have the same name as the input file, except that instead of ending".txt", it should end".html" the rules We'll only be working with a very small part of HTML in this assignment. You're welcome to add more if you'd like, but at a minimum, the HTML output should begin: and should end: Other transformations from the input file to HTML should be done according to the following: If a line begins and ends with an underscore character (_, the program should output the contents of that line (minus the leading and trailing underscores) within an h1 header tag. For example, if the line contained the text _Big Important Point_ the program would output:

Big Important Point

Blank lines are replaced with HTML paragraph tags, i.e., |

(You do not have to close paragraphs with an XHTML-style closing paragraph tag

). Lines that begin with a' character (i.e. a minus sign) are considered to be bullet points of an unordered list o In your output, lists should begin: |
    . Each bullet point in the list will consist of the characters of the line following the '-' in the input, and will be enclosed in list item tags, i.e., |
  • text following the '-'
  • o Lists should end: |
So for example, if in the input file we see: - turkey lettuce - tomato - little bit of mayo Your program would output
  • turkey11>
  • lettuce
  • tomato
  • little bit of mayo
Any line that doesn't match any of the previous rules will be output as is, but with a line break tag
at the end An Example If the input file is _shanty. who lives in a pineapple under the sea? Spongebob Squarepants - absorbent - yellow - porous is he, Spongebob Squarepants The program would output:

shanty

who lives in a pineapple under the sea?
Spongebob Squarepants

  • absorbent
  • yellow
  • porous

is he, Spongebob Squarepants
which, when rendered in a web browser, would look something like: shanty Who lives in a pineapple under the sea? Spongebob Squarepants absorbent yellow porous is he, Spongebob Squarepants outputting URLs Any text in the input file of the form [[X][Y]] should be treated as a hyperlink, where X is the URL, and Y is the text to display on the screen. For example, if X is http://www.cis.temple.edu/wjfiore/2021/ spring/1868 and Y is class, your program should output a hyperlink that displays the text class, which when clicked takes the user to the page http://www.cis.temple.edu/wjfiore/2021/ spring/1068. You are not required to handle the possibility that one of these blocks begins and ends on different lines of the input file exceptions Remember that you are not required to handle FileNotFoundException using try-catch-finally blocks. We'll cover these later in the semester. For now, it is only necessary to add the clause throws FileNotFoundException to each function where you write new File or any function that calls a function that has a throws FileNotFoundException clause. You'll find examples of this in our classnotes. description In this assignment, you'll write a Java program which asks the user to enter the name of a plain text file. The program reads the file and then outputs an html version according to the guidelines provided. The purpose of the assignment is to provide some practice reading and writing files as well as reinforcing what you've learned about handling Strings If you're unfamiliar with the basics of HTML or need a refresher, you can learn more at w3schools. file names The user should enter the name of an input file which ends ".txt". The output file should have the same name as the input file, except that instead of ending".txt", it should end".html" the rules We'll only be working with a very small part of HTML in this assignment. You're welcome to add more if you'd like, but at a minimum, the HTML output should begin:

and should end: Other transformations from the input file to HTML should be done according to the following: If a line begins and ends with an underscore character (_, the program should output the contents of that line (minus the leading and trailing underscores) within an h1 header tag. For example, if the line contained the text _Big Important Point_ the program would output:

Big Important Point

Blank lines are replaced with HTML paragraph tags, i.e., |

(You do not have to close paragraphs with an XHTML-style closing paragraph tag

). Lines that begin with a' character (i.e. a minus sign) are considered to be bullet points of an unordered list o In your output, lists should begin: |
    . Each bullet point in the list will consist of the characters of the line following the '-' in the input, and will be enclosed in list item tags, i.e., |
  • text following the '-'
  • o Lists should end: |
So for example, if in the input file we see: - turkey lettuce - tomato - little bit of mayo Your program would output
  • turkey11>
  • lettuce
  • tomato
  • little bit of mayo
Any line that doesn't match any of the previous rules will be output as is, but with a line break tag
at the end An Example If the input file is _shanty. who lives in a pineapple under the sea? Spongebob Squarepants - absorbent - yellow - porous is he, Spongebob Squarepants The program would output:

shanty

who lives in a pineapple under the sea?
Spongebob Squarepants

  • absorbent
  • yellow
  • porous

is he, Spongebob Squarepants
which, when rendered in a web browser, would look something like: shanty Who lives in a pineapple under the sea? Spongebob Squarepants absorbent yellow porous is he, Spongebob Squarepants outputting URLs Any text in the input file of the form [[X][Y]] should be treated as a hyperlink, where X is the URL, and Y is the text to display on the screen. For example, if X is http://www.cis.temple.edu/wjfiore/2021/ spring/1868 and Y is class, your program should output a hyperlink that displays the text class, which when clicked takes the user to the page http://www.cis.temple.edu/wjfiore/2021/ spring/1068. You are not required to handle the possibility that one of these blocks begins and ends on different lines of the input file exceptions Remember that you are not required to handle FileNotFoundException using try-catch-finally blocks. We'll cover these later in the semester. For now, it is only necessary to add the clause throws FileNotFoundException to each function where you write new File or any function that calls a function that has a throws FileNotFoundException clause. You'll find examples of this in our classnotes

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions