From 162229b5a516ca2b723056e3a5d8ad27e0ae799a Mon Sep 17 00:00:00 2001 From: WiserJ Date: Tue, 26 Oct 2021 19:59:50 -0700 Subject: lab final --- CST116F2021-Lab4/CST116F2021-Lab4.cpp | 83 +++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) 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 //* -- cgit v1.2.3