CS计算机代考程序代写 Excel Haskell Coursework 3

Coursework 3
Purpose: To develop the same program in both C and Haskell so that the two versions behave exactly the same way.
Submission: Upload to Moodle before 16:00pm 19th May 2021. To submit, create and upload a zip file containing the source code of your two programs, each in a separate sub-directory, and your report document file (must be in pdf). Compiled code is not required just the source. Please use the standard .zip format and no other variations (not rar, 7-zip, or anything else!).
Marking: This coursework is worth 60% of the module mark. It is better to submit well-written, working code that covers a majority of the specification, rather than poorly written code that tries to do everything.
Inadequate (0-39)
Failed to demonstrate a basic understanding of the concepts used in the coursework, or answer the questions. There are fundamental errors, code will not compile, or run, or nothing of significance has been achieved. Very poor report. (F)
Just Adequate (40-49)
Shows a basic understanding, sufficient to achieve a basic pass, but still has serious shortcomings. Code may compile but doesn’t work properly. Not all concepts have been understood or the specification is only partly implemented correctly. Report is just good enough but not well written. (D)
Competent (50-59)
Reasonable understanding but with some deficiencies. The code compiles and runs, the concepts are largely understood. This is the default for a straightforward, satisfactory answer. Most of the specification has been implemented, report is reasonable. (C)
Good (60-69)
A good understanding, with possibly a few minor issues, but otherwise more than satisfactory. The code compiles, runs and demonstrates good design practice. Most expectations have been met. The complete specification has been implemented. Quite good, clear report. (B)
Very Good (70-79)
A very good understanding above the standard expectations, demonstrating a clear proficiency in programming and design. Complete specification implemented very well, very good report showing good insight into the design and programming process. (A)
Excellent (80-100)
Programming at a level well above expectations, demonstrating expertise in all aspects. This level is used sparingly only where it is fully justified. Complete specification implemented excellently, excellent report with real depth and insight. (A+, A++)
Q1. Implement two versions of the program specified below, one in C, the other in Haskell. (2 x 35%).
Q2. Write a report on your work with this content (30%):
! Section 1: Summarise what each program can do, half a page maximum.
! Section 2: Describe and evaluate your design and programming process for each program. In particular, compare and contrast the process for C with that for Haskell.
! Section 3: State, and justify, whether you believe C or Haskell is the best language for writing the program. Note, what matters is how you justify your choice for this program, it is not the case that
1 of 4

one language is by default better than the other.
! The overall report should be a maximum of 2 pages (sides of A4 paper) in length. Favour clarity and conciseness over length.
Specification
Implement the two versions of the program for as much of the specification listed below that you have time to complete. You should use the standard C and Haskell tools and default libraries that you used when taking the module during term 1. You should not add any third-party libraries, or write code that will not work with the standard tools. For Haskell, see chapter 9 of “Learn You a Haskell” if you need some help with reading from a file.
The amount of code required for each program should be relatively small, sufficient to produce a working answer. The code should be well-designed and written.
Each program should read its input from a file containing the HTML document to check, in plain text format (i.e., created using a normal editor such as Visual Studio Code), and:
• Confirm that each tag is a valid HTML tag (see below for which tags).
• Check that each tag has a corresponding closing tag if needed.
• Check that the tags are nested properly.
• Check that there are and tags around the entire document.
• Check that there is a single … section followed by a single … section in that order.
If an error is found an error message should be displayed and the program stops, so only the first error found is reported. If no errors are found the program should display a simple message that the HTML was correct.
Constraints:
• You must work with the following subset of HTML tags only, not every tag! This mandatory subset is {html, body, title, h1, h2, h3, p, ul, li, a, div, br, hr}. Don’t include any other tags.
• A

tag cannot be nested inside a

tag, and a

tag cannot be nested inside a

tag. A

tag can nest inside another

.

is one of the few tags that doesn’t have a closing tag, so documents can contain just
. Similarly for


.
• Any attributes in an opening tag are ignored. For example, in

the class attribute is ignored.
• The tag is included in the head section between the head tags only, and not in the body section between the body tags.<br /> • A DOCTYPE at the start of the document is not required.<br /> • Assume there are no comments (<!-- -->) or entities (e.g., < to represent <) in the HTML document. • Assume that the ‘<’ and ‘>’ characters are used only as part of the HTML tags, and do not appear in the text within p, h1, h2, h3, or any other sections, or in attribute values.<br /> • The input file name should be fixed as ‘file.html’. You do not need to add code to ask for a file name and input a file name. The program always reads from file.html.<br /> 2 of 4</p> <p>An HTML tag is what appears between the angle brackets, for example </p> <h1> or </p> <p>. A closing tag has a ‘/’ character before the tag name, for example </h1> <p> or </p> <p>. <br /> does not need a matching closing tag </br>, likewise for </p> <hr> <p>.<br /> An example of a complete valid HTML document based on the specification above is:<br /> <html><br /> <head><br /> <title>Example Document

A Title

A paragraph with words and sentences.

A SubTitle

More text and a link: UCL CS


  • List item 1

  • List item 2



The class and href words are attribute names followed by an attribute value in quotes. These attributes and values should be skipped over when checking the tags, meaning for example that

is treated as

.
Some examples of invalid sections within a document are listed here (these examples are not complete documents and are not an exhaustive list):
1. Invalid nesting

as the closing

tag is not properly nested inside the enclosing

tags.
2. p incorrectly nested in another p

3. div incorrectly nested in a p

3 of 4

4. Invalid tag name

5. Missing closing tag

The

between the

and

has no matching

.
6. Missing opening tag

The

between the

and

has no matching

. 7. Missing head section




8. Missing angle bracket

9. Invalid use of ‘<’ or ‘>’ characters

This is some text using these characters, < and >.

The angle bracket characters should only be used for tags.
10. title included within the body section

<br />

4 of 4