diff options
Diffstat (limited to 'BlankConsoleLab/CST116-Lab1-Havaldar.cpp')
| -rw-r--r-- | BlankConsoleLab/CST116-Lab1-Havaldar.cpp | 39 |
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; |