From 78bdf36f3c9ea3181c1aef01151e90c745ee2a2e Mon Sep 17 00:00:00 2001 From: twsta Date: Tue, 11 Oct 2022 20:05:40 -0700 Subject: added checks for too large and too small dimensions --- BlankConsoleLab/BlankConsoleLab.cpp | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/BlankConsoleLab/BlankConsoleLab.cpp b/BlankConsoleLab/BlankConsoleLab.cpp index da5b275..fca81a9 100644 --- a/BlankConsoleLab/BlankConsoleLab.cpp +++ b/BlankConsoleLab/BlankConsoleLab.cpp @@ -8,18 +8,32 @@ int main() float area, ratio; cout << "Kite Math 0.2" << endl; - cout << "Please input the width of your kite:" << endl; - cin >> width; - cout << "Please input the length of your kite:" << endl; - cin >> length; - cout << endl; + + do { + cout << "Input the width of your kite:" << endl; + cin >> width; + if (width < 1 || width > 400) + cout << "Input a valid number." << endl; + cout << endl; + } while (width < 1 || width > 400); + + do { + cout << "Input the length of your kite:" << endl; + cin >> length; + if (length < 1 || length > 400) + cout << "Input a valid number." << endl; + cout << endl; + } while (length < 1 || length > 400); + cout << "Width: " << width << endl; cout << "length: " << length << endl; + area = (width * length) / 2; area = area / 10000; ratio = width / length; + cout << "Ratio: " << ratio << endl; if (ratio >= 1) { cout << "A lower aspect ratio may provide more kit stability" << endl; } -- cgit v1.2.3