// Example 3.2. Program to display the floor space for a room #include using namespace std; int main() { void directions(); // prototypes int getDim(); int area(int dim1, int dim2); int dim1; // one dimension of the room int dim2; // another dimension of the room int floorSpace; // area of floor in room directions(); dim1 = getDim(); dim2 = getDim(); floorSpace = area(dim1, dim2); cout << endl << "The floor space is " << floorSpace << " square feet." << endl; return 0; } // // Function to print program directions // Pre: none // Post: Program directions have been printed. // void directions() { cout << "This program will give you the floor space "; cout << "in square feet" << endl; cout << "for a room of your choosing." << endl << endl; } // // Function to prompt the user for one dimension // of a floor and to return that dimension // Pre: none // Post: The function has returned an integer dimension. // int getDim() { int dimension; // one dimension of floor cout << "Type one dimension of the floor in feet: "; cin >> dimension; return dimension; } // // Function to calculate the floor space (area of the floor) // given two dimensions (length and width). // Pre: dim1 and dim2 are integer dimensions. // Post: The function has returned the integer floor space. // int area(int dim1, int dim2) { return (dim1 * dim2); }