SOURCE FILE: 190_floorSpace02.cpp


/* 
   Program to display the floor space for a room   
   
   Fleshed-out design 
     + function calls added to the  main function, 
       as the designer wishes them to be 
     + in-line code added that completes the 
       executable statements needed in main

   Still missing: 
      + Declarations of variables
      + Declarations (prototypes) of functions
      + Definitions of functions
 
   So far, the designer has only entered calls to non-existent
   functions.  This "program" has syntax errors, so we can't compile
   it and test it.

*/

#include <iostream>
using namespace std ;

/* ================================== */
/* ================================== */

int main(void)   
{   
         /* Step One: Print Directions for the user.  We have written
            a function CALL to perform this step of printing
            directions.  After we insert more code in this program -
            code that declares and defines the function, then this
            function call will be a trigger that causes the function
            to execute. The function is like another program - a
            sub-program that will do the job of printing the
            directions for the main program. */

   directions() ; // This is a function CALL

        /* Step Two: Get the dimensions of the floor from the user.
           These are two more function CALLS.  Their form is
           different.  We will declare and define the GetDim()
           function in such a way that it returns a value.  The reason
           we place the calls in assignment statements is so we can
           store the values returned.  Those values dim1 and dim2
           represent the width and length of a floor.  The purpose of
           the GetDim() function is to obtain a value from the user of
           this program.  */

   dim1 = GetDim();  // There are function calls on the right hand
   dim2 = GetDim();  // side (RHS) of an assignment statement
   
       /* Step Three: IF   either dimension is not positive
                           print an error message
                      ELSE Compute FloorSpace as product and 
                           print the answer out for the user to see
       */
   if ( (dim1 <= 0) || (dim2 <= 0) )      // invalid data 
   {    
      cout << "\nSorry, only positive dimensions are allowed.\n";
      cout << "Please reexecute the program.\n\n";
   }   
   else  // valid data 
   {   
      FloorSpace = area(dim1, dim2);   

      /* Above is another function call on the RHS of an assignment
         statement.  The function area() will be designed with two
         PARAMETERS - values that we need to give to the function when
         we call it. In this case, the parameters are two dimensions,
         and the area() function returns the product of the two
         dimensions. */

      cout << "\nThe floor space is " << FloorSpace << " square feet.\n\n";

   }   
/*   
   Notes on solution method:
     * Use function to print directions
     * Make a function that gets one dimension and use 
       it twice to get the dimensions of the floor
     * Use a function to calculate the floor space
     * Do the rest with explicit code in main
*/

   return 0;
}