Creating HTML Grade Sheets from C++: An Instructional Example, Exercises of Computer Programming

A c++ programming assignment where students create a program to generate html code for a grade sheet based on a given grade file. The structure of the grade file and html code, and provides instructions for creating the program. It emphasizes the importance of testing and delivering the correct outputs.

Typology: Exercises

2012/2013

Uploaded on 04/27/2013

nazi
nazi 🇮🇳

4.5

(16)

48 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Purpose
practice analyzing a problem statement
practice while loops
practice functions
practice incremental development
Introduction
Some instructors at your university want to publish their grades on the web. They want web pages that look
something like this:
CPSC230-01,
SPRING 01
NAME
MIDTERM
FINAL
GRADE
able
90
90
A
baker
80
80
B
charlie
70
70
C
delta
60
60
D
fox
59
59
F
echo
0
0
F
Sample web page for a grade sheet.
But, in order to do that, they would have to write code that looks like this:
<HTML>
<TITLE>GRADE INFORMATION</TITLE>
<BODY>
<H1>CPSC230-01, SPRING 01</H1>
<TABLE BORDER=1>
<TR>
<TD>NAME</TD><TD>MIDTERM</TD><TD>FINAL</TD><TD>GRADE</TD>
</TR>
<TR>
<TD>able</TD><TD>90</TD><TD>90</TD><TD>A</TD>
</TR>
<TR>
<TD>baker</TD><TD>80</TD><TD>80</TD><TD>B</TD>
</TR>
<TR>
<TD>charlie</TD><TD>70</TD><TD>70</TD><TD>C</TD>
</TR>
<TR>
<TD>delta</TD><TD>60</TD><TD>60</TD><TD>D</TD>
</TR>
<TR>
<TD>fox</TD><TD>59</TD><TD>59</TD><TD>F</TD>
</TR>
<TR>
<TD>echo</TD><TD>0</TD><TD>0</TD><TD>F</TD>
</TR>
pf3

Partial preview of the text

Download Creating HTML Grade Sheets from C++: An Instructional Example and more Exercises Computer Programming in PDF only on Docsity!

Purpose

  • practice analyzing a problem statement
  • practice while loops
  • practice functions
  • practice incremental development

Introduction

Some instructors at your university want to publish their grades on the web. They want web pages that look something like this:

CPSC230-01,

SPRING 01

NAME MIDTERM FINAL GRADE

able 90 90 A baker 80 80 B charlie 70 70 C delta 60 60 D fox 59 59 F echo 0 0 F Sample web page for a grade sheet.

But, in order to do that, they would have to write code that looks like this:

GRADE INFORMATION

CPSC230-01, SPRING 01

NAMEMIDTERMFINALGRADE

able9090A

baker8080B

charlie7070C

delta6060D

fox5959F

echo00F

HTML Code for a table.

You have been asked therefore, to write a C++ program that will read an instructor's grade file and produce the corresponding HTML code. In order to accomplish this task, you need to know the parts of the grade file, and the structure of HTML code, especially tables. This information is given in the next two sections.

Grade File Structure

The first line of the file lists the course number and section. The second line contains the semester and year. The third line is an integer indicating the number of students that follow. In this example, there are 6 students. Each student is listed on a line as follows: the first word is the student nickname; a space follows, then the midterm grade, another space, then the final grade.

CPSC230 01 SPRING 01 6 able 90 90 baker 80 80 charlie 70 70 delta 60 60 fox 59 59 echo 0 0 Contents of the grade file used to produce the table above.

HTML Table Structure

An HTML file contains tags, such as and . A tag is a way of marking sections of text with formatting information. For example, all the text in between and is to be formatted as a heading. In the example above, the heading is in bold , large text. A table is marked by the and tags. Each row in the table is marked by and , and each cell in a row is marked by and .

Converting Grade to Table

The html heading is made up of the course number, a dash, the section, a comma, a space, the semester, a space, then the year. The table then immediately follows. The table's first row shows four cells: NAME, MIDTERM, FINAL, GRADE. Each student row in the table contains the name, midterm, final, and grade of that student. Note that the grade is not present in the grade file, but must be computed from the average of the midterm and final. If the average is 90 and above, the grade is an 'A', 80-89 is 'B', 70-79 is 'C', 60-69 is 'D', and anything else is 'F'.

Instructions

TEST your code!!! I will be testing your code. You want to catch as many errors (and fix or document them) before I catch them. This is what happens in the industry. As a professional you will want to catch as many errors as you can, instead of suffering the embarasment of having your users catch them! How do you test your code? Think about possibilities and consequences. What kind of grades could be present? Does my code correctly calculate the grades? Does my program generate the correct HTML code? Don't wait until you have written all the code to test it! Separate the problem into smaller pieces, and develop and test each piece separately. You must use functions in your code.

Deliverables

Submit hard copy of your source code;

Submit hard copy of your running results. (snapshot)

Submit hard copy of contents of your HTML file. (snapshot)