summaryrefslogtreecommitdiff
path: root/BlankConsoleLab/BlankConsoleLab.cpp
diff options
context:
space:
mode:
authorMorgan Cyrus <[email protected]>2022-10-19 17:22:41 -0700
committerMorgan Cyrus <[email protected]>2022-10-19 17:22:41 -0700
commitf091fafce8fd3469d8d1c58ee0fa61c33dfb3639 (patch)
treef9f3a49456b2f77972713a0f0b7cd57c3cf740a5 /BlankConsoleLab/BlankConsoleLab.cpp
parentPart 1 finished (diff)
downloadcst116-lab1-cyrus-f091fafce8fd3469d8d1c58ee0fa61c33dfb3639.tar.xz
cst116-lab1-cyrus-f091fafce8fd3469d8d1c58ee0fa61c33dfb3639.zip
Entered while loops for mandating input between 1 and 400
Diffstat (limited to 'BlankConsoleLab/BlankConsoleLab.cpp')
-rw-r--r--BlankConsoleLab/BlankConsoleLab.cpp24
1 files changed, 17 insertions, 7 deletions
diff --git a/BlankConsoleLab/BlankConsoleLab.cpp b/BlankConsoleLab/BlankConsoleLab.cpp
index e192845..e381995 100644
--- a/BlankConsoleLab/BlankConsoleLab.cpp
+++ b/BlankConsoleLab/BlankConsoleLab.cpp
@@ -1,9 +1,9 @@
/*
* BlankConsoleLab.cpp : This file contains the 'main' function.Program execution begins and ends there.
-*
+*
* Morgan Cyrus
-* CST116_Lab1_Cyrus
-* Kite Lab
+* CST116_Lab1_Cyrus
+* Kite Lab
*/
#include <iostream>
@@ -21,10 +21,20 @@ int main()
float kiteLen = 0;
float kiteArea = 0;
- cout << "Enter value for kite width in cm: ";
- cin >> kiteWidth;
- cout << endl << "Enter value for kite length in cm: ";
- cin >> kiteLen;
+ // get user input for kiteWidth. Value entered must be between 1 and 400 or it will loop and ask again.
+ while(kiteWidth < 1 || kiteWidth > 400)
+ {
+ cout << "Enter value for kite width in cm between 1 and 400 cm: ";
+ cin >> kiteWidth;
+ }
+
+ // get user input for kiteLen. Value entered must be between 1 and 400 or it will loop and ask again.
+ while(kiteLen < 1 || kiteLen > 400)
+ {
+ cout << endl << "Enter value for kite length in cm: ";
+ cin >> kiteLen;
+ }
+
cout << "\nYou have entered " << kiteWidth << "cm for kite width, and " << kiteLen << "cm for kite length." << endl;