For this assignment you are to write a C++ function. You may may call the function what you want but since you are having trouble call the function gradePage. This function has one argument, a string, and returns a string. So the function looks like:

string gradePage(string name) { some code here }

The input to the fucntion is a name of a student like "Olson" or "Whitney". Now for the return value. THe first part of the returned string is:

[html lang="en"][head][meta http-equiv="content-type" content="text/html; charset=utf-8"][title]Sample Output[/title][/head][body]

One can add optional spaces between the tags and change the title. Since that is optional you can just make the first part of the to be the above text. The end of the string is always:

[/body][/html]

Now for the middle part of the string. To talk about this we need a table, which is like a two dimension array. It has rows and columns. We are going to represent the table in a string with some simple syntax. The syntax of the table is as follows. The table starts with "[table]" and ends with "[/table]". Each row starts with "[tr]" and ends with "[/tr]". Each element in the table start with "[td]" followed by the element and ends with "[/td]". So the two dimension array:

a b
c d

would look like:

[table][tr][td]a[/td][td]b[/td][/tr][tr][td]c[/td][td]d[/td][/tr][/table]

If you like you can add some spaces between the tags, but that is optional. Now going from the two dimesional array format to this html syntax requires some work.

So the other thing you need to do is create a class. Lets call it HtmlTable. The class needs a constructor with two arguments, the number of rows and the number of columns. The class also needs a way to add elements to the table. Lets call that method put. The method needs three arguments: row index, column index, and the value to add. The class also needs a to_string() method. The to_string() method produces the html table syntax. So we could write:

HtmlTable example = new HtmlTable(2,2);
example.put(0,0,"a");
example.put(0,1,"b");
example.put(1,0,"c");
example.put(1,1,"d");
string result = example.to_string();

Now result contains the string "[table][tr][td]a[/td][td]b[/td][/tr][tr][td]c[/td][td]d[/td][/tr][/table]".

There are a few other things the class should do but this gets most of the way there. Once we have the HtmlTable class we can use it to create the middle part of the string returned by function gradePage. It will do the work adding all the tags to the table.

So we now need to talk about the middle part of the string returned by gradePage. It is the grade table for a student. The data comes from a file. Call the file "grades.txt" for now. Here is a sample "grades.txt" file:

Name,Assignmt1,Assignmt2,Quiz1,Assignment3
Pete,10,5,8,9
Sam,8,10,4,10
Sally,9,9,10,8
June,8,7,12,10
Max Points,10,10,12,10

From this we need to create the grade table for the method gradePage. However the table is slightly different for each student. So to have a concrete example lets build the table for "Sally". That is we are working on the table created in gradePage("Sally"). The first line of the table we are creating is the first line of the input file. The third line of the table we are creating is the last line of the input file. The second line of the table we are creating is the line in the input file that starts with the students name. So the first three lines of the table we are creating are:

Name,Assignmt1,Assignmt2,Quiz1,Assignment3
Sally,9,9,10,8
Max Points,10,10,12,10

Now for the rest of the table. Since there are 4 students in the class there will be 4 more lines of the table. It is easier to describe the colunms then the rows. The first column will have the numbers 1 through 4. The second column will contain all the grades from assignmt1 in sorted order. That is 10,9,8,8. The third column will contain all the grades from assignmt2 in sorted order, That is 10,9,7,5. Each of the rest of the colums are just the grades from that column in the input file sorted. So the table for Sally is:

Name,Assignmt1,Assignmt2,Quiz1,Assignment3
Sally,9,9,10,8
Max Points,10,10,12,10
1,10,10,12,10
2,09,09,10,10
3,08,07,08,09
4,08,05,04,08

Lets call this the grade table for Sally. Now we can specify what gradePage does.

string gradePage(string name) {
1. Create the grade table for the student indicated by the parameter "name"
2. Use the class HtmlTable to convert the grade table from step 1 into html format.
3. To the front of the result of step 2 add the string [html lang="en"][head][meta http-equiv="content- type" content="text/html; charset=utf-8"][title]Sample Output[/title][/head][body]
4. To the end of the result of step 3 add [/body][/html]
5. Return the result of step 4.
}

I left out a few details, but once you understand the above the those details should be a bit clearer. Also a number of things that I specified above have options (like the actualy names of classes, methods, and functions) so don't panic if you used different ones. Now you are correct that the assignment requires several things not covered in class. In a 300 level computer science course I think it is reasonable to expect that students can read on their own how to open a file and read the contents.

Academic Honesty!
It is not our intention to break the school's academic policy. Projects posted are only used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly fill out the form. Please provide a valid email address and we'll get back to you in less than 24 hours. We will be sending an invoice through PayPal upon confirmation. We are a non profit organization however we need an amount to keep this organization running, and to be able to complete our research and development.