summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDoolyBoi <[email protected]>2022-10-19 20:04:11 -0700
committerDoolyBoi <[email protected]>2022-10-19 20:04:11 -0700
commitf034dbed3b231851051d5d2dc8c2fe44d458e4c3 (patch)
treef955a0a951408d648b86ee8eed5d10db7da50e1d
parentpart 1 completed (diff)
downloadcst116-lab1-abd00l4h-f034dbed3b231851051d5d2dc8c2fe44d458e4c3.tar.xz
cst116-lab1-abd00l4h-f034dbed3b231851051d5d2dc8c2fe44d458e4c3.zip
made while loop to ask user input multiple times
-rw-r--r--BlankConsoleLab/BlankConsoleLab.cpp26
1 files changed, 21 insertions, 5 deletions
diff --git a/BlankConsoleLab/BlankConsoleLab.cpp b/BlankConsoleLab/BlankConsoleLab.cpp
index 1c8c8f6..224af44 100644
--- a/BlankConsoleLab/BlankConsoleLab.cpp
+++ b/BlankConsoleLab/BlankConsoleLab.cpp
@@ -21,13 +21,27 @@ int main()
{
//seting up variables
float length, width, area, aspectRatio;
+ bool dimensions = false;
- //output prompt for user to enter length and width
- cout << "Please enter the length and width of your kite (in that order)." << endl;
- cin >> length >> width;
+ //keeps on looping until the user inputs a length and a width between 1 and 400
+ while (!dimensions)
+ {
+ //output prompt for user to enter length and width
+ cout << "Please enter the length and width of your kite (in that order)." << endl;
+ cin >> length >> width;
+
+ //output confirmation stating what the user input
+ cout << "So the length is " << length << "cm and the width is " << width << " cm." << endl;
- //output confirmation stating what the user input
- cout << "So the length is " << length << "cm and the width is " << width << " cm." << endl;
+ if (width > 400 || length > 400 || width < 1 || length < 1)
+ {
+ cout << "Please enter a width and length between 1 - 400. " << endl;
+ }
+ else {
+ dimensions = true;
+ break;
+ }
+ }
//calculating area and turning it to square meteres
area = ((width * length) / 2);
@@ -46,5 +60,7 @@ int main()
}
+
+
}