summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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()
}
+
+
}