Sequential and Conditional Programming

The objective for today's lab is to investigate the differences between sequential and Conditional programming.

  1. Paste the following code into Eclipse or cpp.sh
    #include <iostream>
    using namespace std;
    // Programmer:

    // This program prompts the user for a non-zero length and
    // width of the house and then computes the perimeter of the house
    //
    //Variable Dictionary
    //length_of_house    input by the user as a double length
    //width_of_house     input by the user as a double width
    //perimeter           perimeter of the house, calculated by the programmer
    //************************************************************************

    int main()
    {
        double length_of_house, width_of_house;
        double perimeter;
       
       //Shouldn't we ask the user to input???
        cin >> width_of_house;
        cin >> length_of_house;

        //What if the user enters 0???
        perimeter = 2*(length_of_house+width_of_house);

        cout << "The perimeter is \n" << perimeter;
        //Shouldn't we also print out the input values??

        return 0;
    }
  2. Save the code somewhere
  3. Run the code
  4. Update the comments
  5. Place a cout at the end of the code to print your name
  6. Put couts in the code to prompt the user for the length and width
  7. Put couts in the code to print out the input values for length and width
    Sample
  8. House length cannot be less than 24 nor bigger than 75
  9. Use conditionals to verify the length and if invalid, output an error message and do not continue the program.
    Length compared to 24
    Improved Length compared to 24
    Length compared to 24 and 75
    Improved Length comparison for 24 and 75
  10. House width cannot be less than 36 nor bigger than 100
  11. Use conditionals to verify the width and if invalid, output an error message and do not continue the program.