// func1.cpp
// Version: 1.0
// Purpose: Demonstrate use of C++ functions.

#include <iostream>
using namespace std;

//---- Interfaces (function prototypes): ----

double RectArea (double width, double height);
// Arguments:
//   width - width of a rectangle
//   height - height of a rectangle
// Returns: area of the specified rectangle.

double BoxVolume (double width, double height, double depth);
// Arguments:
//   width - width of a rectangular box
//   height - height of a rectangular box
//   depth - depth of a rectangular box
// Returns: volume enclosed by the specified box.


//---- Main function ----
void main ()
{
	cout << "Starting main function" << endl;

	double initial_width = 11;
	double initial_height = 3;
	double initial_area;
	initial_area = RectArea (initial_width,initial_height);

	cout << "Width = " << initial_width << endl;
	cout << "Height = " << initial_height << endl;
	cout << "Area = " << initial_area << endl;

	// Now see what happens to the area is we decrease the
	// width and then increase the height by the same amount.
	double new_width;
	double new_height;
	double new_area;
	new_width = initial_width - 2;
	new_height = initial_height + 2;

	cout << "New width = " << new_width << endl;
	cout << "New height = " << new_height << endl;

	new_area = RectArea (new_width, new_height);
	cout << "New area = " << new_area << endl;
	cout << endl;

	double box_width = 5;
	double box_height = 3;
	double box_depth = 4;
	cout << "Box width = " << box_width << endl;
	cout << "Box height = " << box_height << endl;
	cout << "Box depth = " << box_depth << endl;
	cout << endl;

	// Calculate the volume of a rectangular box.
	double box_volume = BoxVolume (box_width, box_height, box_depth);
	cout << "Box volume = " << box_volume << endl;
	cout << endl;

	cout << "End of main function" << endl;
}







//---- Function implementation ----

double RectArea (double width, double height)
{
	double area;

	cout << "RectArea: width = " << width;
	cout << ", height = " << height << endl;

	area = width * height;

	cout << "RectArea: area is " << area << endl;

	return area;
}

double BoxVolume (double width, double height, double depth)
{
	double volume;
	cout << "BoxVolume: width = " << width;
	cout << ", height = " << height;
	cout << ", depth = " << depth << endl;
	cout << endl;

	volume = RectArea(width,height) * depth;

	cout << "BoxVolume: volume is " << volume << endl;
	return volume;
}