/* C++ style demonstration program
 * by R. P. Futrelle, ID 123456789
 * COM1100 Fall 2000
 * College of Computer Science
 * Northeastern University
 *
 * Version 1.0, 10/11/2000
 * File: rpfexamp.cpp
 */

/* Creates HTML code, written to cout.
 * Demonstrates C++ programming practices, layout.
 * Contains:
 *   Function declarations (prototypes)
 *   Functions with arguments and return values
 *   Functions calling other functions
 *   Functions embedded in output sequences
 *   Output string escape sequences
 */

/* Note the use of indentation, blank lines and
 * other white space, as well as grouping related
 * lines together.  Not only is there white space in 
 * the source code, but white space (extra newlines)
 * are added to the HTML output to make it more readable.
 *
 * Comments do not repeat the obvious content of statements.
 * Instead, the explain their role, their importance
 * and what they do.
 */

// start of the program proper:

#include <iostream>
#include <string>   // something extra
using namespace std;

// Function prototypes, not commented here but in definitions below.

// HTML functions:

void startHTML();
void endHTML();
void titleIt(string);
void me();
void bigAndSmall(int);

// Numerical functions:

float bigNumber(int);
float smallNumber(int);

// The main() generates the HTML code, meant for a browser.
int main()
{
	int intParameter = 33, pause;
	string myTitle = "C++ style demo program, V1.0, October 2000.";

	startHTML();
	titleIt(myTitle);
	me();
	bigAndSmall(intParameter);
	endHTML();

	cin >> pause; // pauses waiting for input (in Debug mode)

	return 0;
}

/*
   Function defintions
*/

// The obligatory tags that begin an HTML document
// Note the use of newlines '\n' instead of the more
// cumbersome << endl.
void startHTML()
{
	cout << "<html>\n   <body> \n\n";

}

// The closing tags, balancing the ones in startHTML()
void endHTML()
{
	cout << "   </body>\n</html> \n";
}

// Places a large title at the top of the web page
void titleIt(string s)
{
	cout << "<h2>" << s << "</h2> \n\n";
}

// Prints the authors name, in an HTML paragraph.
void me()
{
	cout << "<p>by R. P. Futrelle</p> \n\n";
}

// This puts out the line with the two values in it.
void bigAndSmall(int n)
{
	cout << "The big number: " << bigNumber(n)
		 << " and the small one: " << smallNumber(n) << "\n\n";
}

// The two functions to compute "big" and "small" numbers

float bigNumber(int n)
{
	return n * 3846457.44;
}

float smallNumber(int n)
{
	return n * 0.0000341;
}

//************************************************************

// Here is the HTML produced by running the code above:

/*
  
  <html>
   <body>

<h2>C++ style demo program, V1.0, October 2000.</h2>

<p>by R. P. Futrelle</p>

The big number: 1.26933e+008 and the small one: 0.0011253

   </body>
</html>

*/

Here is the final HTML as displayed:

C++ style demo program, V1.0, October 2000.

by R. P. Futrelle

The big number: 1.26933e+008 and the small one: 0.0011253