CS23021 Comp Sci I - Project 1: HTML Table with Input & Output of Signed Numbers, Study Guides, Projects, Research of Computer Science

Project 1 for cs23021 computer science i, where students are required to write a c++ program that processes integer inputs and outputs them in an html table based on their signs. The program should use different html font tags to color negative numbers in red and stop reading inputs when a zero is encountered. The output should be redirected to an .html file for viewing in a web browser.

Typology: Study Guides, Projects, Research

Pre 2010

Uploaded on 08/01/2009

koofers-user-g5i
koofers-user-g5i 🇺🇸

10 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CS23021 Computer Science I
Spring 2008, Project #1
Committed by 11:59pm on Friday, October 3, 2008
Preliminaries
Write a program that processes integer number input values and outputs them based upon their sign (+/-) using
different HT ML font tags embedded in HTML tab le tags. The HT ML table will have four columns where the first
three columns contain the numbers read in as inpu t and the fourth column will con tain the the sum of the three input
values in the same row. Any input values (or summation values) th at are negative numbers should be output in red
color. You program should stop reading in input valu es when an input value of 0 (zero) is encountered. The zero
value should not be output as a value in the HTML table. E mpty table ce lls should be output to co mplete the entries
in the las t row of input values in the table, if necessary. Following the last row of input va lues, one add itional row
will need to be output. Th is v ery last row must contain the sum of all numbers in each respective column and the
total of all input numbers in the last cell (bottom righ t side cell of th e table).
The best practice for attacking th is project (or any project for that matter) is to sketch out a design for the different
parts of the control logic before you begin writing the actual c++ code for this program. In other words you need to
have a clear understanding of the problem, inc luding the for m of the input and the desired output. Keep in mind that
the output of you program is an ordered group of HTML tags that encode an HTML table that can contain dynamic
input (i.e. the values read-in by your program). You will us e unix redirect operators to redirect the input and output
streams so that the input and out to you program can be read-in from the comm and line (or input-file) and written
out to an output file tha t you will b e able to view in a HTML browser. More information on the use of these redirect
operators is provided below. Designing your solution before you start writing c++ code w ill save you a tremendous
amount of time and help you to figure out what the specific lines of code will need to be in order to complete this
project.
HTML (HyperText Markup Language) is the language th at is used in writing web-pages. The language consists of
formatting elem ents called HTML tags. A HT ML table s tarts with a <table> tag and ends w ith a </table> tag.
The information in the table is organized by rows. Every table row starts with a <tr> tag and ends with a </tr>
tag. The rows are divided into table cells. Every cell starts with a <td> tag and ends with a </td> tag.
Information entered in the table cell is formatted and displayed by a web browser. The color with which content is
output is controlled by the <font> and </font> tag pair. For examp le, <font color=red> hello,
world </font> displays hello, world in the color red in a browser. More on HTML can be found at various
locations on the internet, such as: http://www .w3schools.co m/html/html_intro.asp. Your program will output, using
cout statements, HTML table tags and the cell values (the values entered as input) so that the table will be
viewable in a browser.
An example of an HTML table formatted as described in this project is ava ilable in file the example.html, which
you can view and download from the course web-site. You can view this f ile in a browser by clicking on it. While
working on your own tables you can always view them in a browser by downloading (sftp) them to your PC and
opening them in a browser (e.g. FireFox, I.E., or some other browser) by selecting “File”“Open ” from the pull-
down menu of your browser.
Your program will r ead-in the input using the standard input stream (cin), and send the ou tput to standard output
stream (cout). You can use the unix/linux redirect operators (< and >) to allow your program to get the values from
a file and send the output to another file. For examp le, the command :
prompt% table < inputfile > table.html
allows the program table to receive input from a file named inputfile (you may use any filename you like –
but the values in the file must conform to the specification of this project) and then all the output of the program
table is sent to a file named table.html The file table.html can be viewed in a browser. Once again, you
pf2

Partial preview of the text

Download CS23021 Comp Sci I - Project 1: HTML Table with Input & Output of Signed Numbers and more Study Guides, Projects, Research Computer Science in PDF only on Docsity!

CS23021 Computer Science I

Spring 2008, Project

Committed by 11:59pm on Friday, October 3, 2008

Preliminaries

Write a program that processes integer number input values and outputs them based upon their sign (+/-) using different HTML font tags embedded in HTML table tags. The HTML table will have four columns where the first three columns contain the numbers read in as input and the fourth column will contain the the sum of the three input values in the same row. Any input values (or summation values) that are negative numbers should be output in red color. You program should stop reading in input values when an input value of 0 (zero) is encountered. The zero value should not be output as a value in the HTML table. Empty table cells should be output to complete the entries in the last row of input values in the table, if necessary. Following the last row of input values, one additional row will need to be output. This very last row must contain the sum of all numbers in each respective column and the total of all input numbers in the last cell (bottom right side cell of the table). The best practice for attacking this project (or any project for that matter) is to sketch out a design for the different parts of the control logic before you begin writing the actual c++ code for this program. In other words you need to have a clear understanding of the problem, including the form of the input and the desired output. Keep in mind that the output of you program is an ordered group of HTML tags that encode an HTML table that can contain dynamic input (i.e. the values read-in by your program). You will use unix redirect operators to redirect the input and output streams so that the input and out to you program can be read-in from the command line (or input-file) and written out to an output file that you will be able to view in a HTML browser. More information on the use of these redirect operators is provided below. Designing your solution before you start writing c++ code will save you a tremendous amount of time and help you to figure out what the specific lines of code will need to be in order to complete this project. HTML (HyperText Markup Language) is the language that is used in writing web-pages. The language consists of formatting elements called HTML tags. A HTML table starts with a tag and ends with a tag. The information in the table is organized by rows. Every table row starts with a tag and ends with a tag. The rows are divided into table cells. Every cell starts with a tag and ends with a tag. Information entered in the table cell is formatted and displayed by a web browser. The color with which content is output is controlled by the and tag pair. For example, hello, world displays “hello, world” in the color red in a browser. More on HTML can be found at various locations on the internet, such as: http://www.w3schools.com/html/html_intro.asp. Your program will output, using cout statements, HTML table tags and the cell values (the values entered as input) so that the table will be viewable in a browser. An example of an HTML table formatted as described in this project is available in file the example.html, which you can view and download from the course web-site. You can view this file in a browser by clicking on it. While working on your own tables you can always view them in a browser by downloading (sftp) them to your PC and opening them in a browser (e.g. FireFox, I.E., or some other browser) by selecting “File”→“Open” from the pull- down menu of your browser. Your program will read-in the input using the standard input stream (cin), and send the output to standard output stream (cout). You can use the unix/linux redirect operators (< and >) to allow your program to get the values from a file and send the output to another file. For example, the command: prompt% table < inputfile > table.html allows the program table to receive input from a file named inputfile (you may use any filename you like – but the values in the file must conform to the specification of this project) and then all the output of the program table is sent to a file named table.html The file table.html can be viewed in a browser. Once again, you

may use any file you like for the output file but it should have the extension .html is you want to easily view it in a browser). Note, that if you are using gdb to debug your program you can use the debugger’s run command to redirect your input/output: (gdb) run < inputfile > table.html

Assignment

Obtain copies of the project files from the course website at: http://www.cs.kent.edu/~volkert/cs23021/S08/. You will need to create a Project2 directory in you cs23021_student directory. You will then need to use the svn add and svn commit commands to put this new directory under subversion control. The file exampleinput contains an example input file that the program can use as input. Note, that your program has to work on ANY line of numbers, not only on the numbers specified in the example file exampleinput, and must be able to process more or less lines of input than are in the example file provided. Test your program with different input integer sequences (you can for instance create a variety of input files to use for testing, or you can simply enter values in from the keyboard). To recap, for this assignment you will write a C++ program table.cpp such that it outputs the tags representing an HTML table with four cells in each row. The first three cells of each row will contain values read-in to the program. The fourth cell of each row will contain the sum of the previous three cells. All negative numbers should be output so that they display in the color red. You are only allowed to use branching and looping constructs as the control structures in your code. You are not allowed to use functions or arrays (material that we have not studied yet). Please not that your table.html file will not show up as a rendered webpage in the svn repository unless you issue a subversion command to set the mime-type of the file. You can do this using the svn propset command as illustrated below

svn propset svn:mime-type text/html table.html

After you have issued the svn propset command you will need to commit the changes using the standard svn commit command. Make sure that your program contains ample comments and otherwise adheres to good programming style. A link to a programming style guide is available on the course webpage. Your grade will be lowered if your do not follow the programming style guidelines outlined there. Have fun with this assignment! If you’re looking to be more creative feel free to experiment with other HTML formatting tags to make your output more colorful.