Call-by-Value, Multiple Files

Lab Assignment

The assignment contains two parts.
  1. Body Mass Index. Study program refactoring described here. As you program your project below, demonstrate to the lab instructor, changing the name of the variable throughout your program through refactoring options.

    Create a project titled Lab5_BMI with a single file titled bmi.cpp The program should calculate the person's Body Mass Index (BMI) and BMI category.

    The BMI formula is as follows:

      BMI = Weight in Pounds * 703 / ((Height in inches) * (Height in inches ))
      
    The BMI categories are calculated on the basis of the person's BMI index as follows:

    The BMI should be calculated by a function bmi that accepts two parameters: "height in inches" and "weight in pounds" and returns the BMI. Note that the BMI has a fractional part.

    The main function should prompt the user for her weight and height, compute the category then output both the BMI and the category. The user should input her height in feet and inches. The main function should compute the total number of inches (one foot has 12 inches) and pass it to the bmi function.

    Make sure to use the bmi function prototype and put the function definition below the main function definition.

  2. Figures. Create a project titled Lab5_Figures. This project will contain multiple files. Write a program that repeatedly asks the user to select either square, left or right triangle, then inputs the figure size and then prints the appropriate shape in stars. The program should quit if the user inputs an invalid option. See an example dialog below:
    1. square
    2. left triangle
    3. right triangle
    select figure: 2
    select size: 4
    *
    **
    ***
    ****
    1. square
    2. left triangle
    3. right triangle
    ...
    

    You can reuse your code from the Looping lab. Place the star-printing code in three separate functions: square, leftTriangle and rightTriangle. Each function should accept a single integer parameter - the size of the figure and return no value (be a void-function). Create three separate files figures.cpp, figures.h, and figuresInput.cpp. Place the triangle and square function definitions in figures.cpp and their prototypes in figures.h. Make sure that the header file is protected against multiple inclusion. Place the main function in figuresInput.cpp

Make sure your programs adhere to proper programming style. Submit your projects to the subversion repository. Do not forget to verify your submission on the web.