summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDoolyBoi <[email protected]>2022-10-19 20:20:27 -0700
committerDoolyBoi <[email protected]>2022-10-19 20:20:27 -0700
commit38e09be0535e831ebbdcae4a9b958d93f509cdb2 (patch)
tree320986f3276a66e1a0bce8aec4e7dcd30a2df796
parentcomments (diff)
downloadcst116-lab1-abd00l4h-38e09be0535e831ebbdcae4a9b958d93f509cdb2.tar.xz
cst116-lab1-abd00l4h-38e09be0535e831ebbdcae4a9b958d93f509cdb2.zip
fixed while loops
-rw-r--r--BlankConsoleLab/CST116-Lab1-Havaldar.cpp39
1 files changed, 28 insertions, 11 deletions
diff --git a/BlankConsoleLab/CST116-Lab1-Havaldar.cpp b/BlankConsoleLab/CST116-Lab1-Havaldar.cpp
index 65f3a9d..5c59eb8 100644
--- a/BlankConsoleLab/CST116-Lab1-Havaldar.cpp
+++ b/BlankConsoleLab/CST116-Lab1-Havaldar.cpp
@@ -22,27 +22,44 @@ int main()
//seting up variables
float length, width, area, aspectRatio, mass, gPull;
bool dimensions = false;
+ bool glength = false;
+ bool gwidth = false;
- //keeps on looping until the user inputs a length and a width between 1 and 400
- while (!dimensions)
+ while (!glength)
{
- //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;
+ cout << "Please enter the length of your kite." << endl;
+ cin >> length;
- //output confirmation stating what the user input
- cout << "So the length is " << length << "cm and the width is " << width << "cm." << endl;
+ if (length > 400 || length < 1)
+ {
+ cout << "Please enter a length between 1 and 400. " << endl;
+ }
+ else
+ {
+ glength = true;
+ break;
+ }
+ }
+
+ while (!gwidth)
+ {
+ cout << "Please enter the width of your kite." << endl;
+ cin >> width;
- if (width > 400 || length > 400 || width < 1 || length < 1)
+ if (width > 400 || width < 1)
{
- cout << "Please enter a width and length between 1 - 400. " << endl;
+ cout << "Please enter a width between 1 and 400. " << endl;
}
- else {
- dimensions = true;
+ else
+ {
+ gwidth = true;
break;
}
}
+ //output confirmation stating what the user input
+ cout << "So the length is " << length << "cm and the width is " << width << "cm." << endl;
+
//calculating area and turning it to square meteres
area = ((width * length) / 2);
area /= 10000;