diff options
| author | WiserJ <[email protected]> | 2021-10-26 19:59:50 -0700 |
|---|---|---|
| committer | WiserJ <[email protected]> | 2021-10-26 19:59:50 -0700 |
| commit | 162229b5a516ca2b723056e3a5d8ad27e0ae799a (patch) | |
| tree | 29b96193bb68e540984a61d79363015cea732990 | |
| parent | post debug (diff) | |
| download | cst116-lab4-jeffwoit-162229b5a516ca2b723056e3a5d8ad27e0ae799a.tar.xz cst116-lab4-jeffwoit-162229b5a516ca2b723056e3a5d8ad27e0ae799a.zip | |
| -rw-r--r-- | CST116F2021-Lab4/CST116F2021-Lab4.cpp | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/CST116F2021-Lab4/CST116F2021-Lab4.cpp b/CST116F2021-Lab4/CST116F2021-Lab4.cpp index 3bf2e6d..35b2440 100644 --- a/CST116F2021-Lab4/CST116F2021-Lab4.cpp +++ b/CST116F2021-Lab4/CST116F2021-Lab4.cpp @@ -6,6 +6,89 @@ using namespace std; +//Prototypes +void GetInput(int& height_input, int& width_input); +void DisplayOutput(int height_output, int width_output); + +int main() +{ + //define variables + int height = 0, width = 0; + + //call input function + GetInput(height, width); + + //call display function + DisplayOutput(height, width); + + return 0; +} + +void GetInput(int& height_input, int& width_input) +{ + //Ask for user input height + do + { + cout << "Please enter the height in characters of the rectangle: "; + cin >> height_input; + } while (height_input <= 0); + + //Ask for user input width + do + { + cout << "Please enter the width in characters of the rectangle: "; + cin >> width_input; + } while (width_input <= 0); +} + +void DisplayOutput(int height_display, int width_display) +{ + //Clarifying Statement + cout << "\nHere is a " << height_display << "x" << width_display << " rectangle.\n"; + + //width adjust per recommendation by Logan (approx. fixes h/w ratio) + width_display *= 2; + width_display += 1; + + //placeholder variables + int tempw = width_display, temph = height_display; + + //Rectangle Display: Top Left Corner + cout << (char)218; + + //Rectangle Display: Top Width Loop + while (width_display != 0) + { + cout << (char)196; + + width_display -= 1; + } + + //Rectangle Display: Top Right Corner + cout << (char)191 << endl; + + //Rectangle Display: Left and Right Sides + while (height_display != 0) + { + cout << (char)179 << setw(tempw+1) << (char)179 << endl; + + height_display -= 1; + } + + //Rectangle Display: Bottom Left Corner + cout << (char)192; + + //Rectangle Display: Bottom Width Loop + while (tempw != 0) + { + cout << (char)196; + + tempw -= 1; + } + + //Rectangle Display: Bottom Right Corner + cout << (char)217 << endl; +} ///******************************************************************** //* File: Chapter 9 Debug.cpp //* |