summaryrefslogtreecommitdiff
path: root/BlankConsoleLab/CST116-Lab1-Fine.cpp
diff options
context:
space:
mode:
authorEdwardFine <[email protected]>2022-10-06 15:31:19 -0700
committerEdwardFine <[email protected]>2022-10-06 15:31:19 -0700
commitcba5229fd833e88dda2cf0e6f1947923bee8fe12 (patch)
tree4846f0c8eca95ac317f53a209e090a0fd18637d8 /BlankConsoleLab/CST116-Lab1-Fine.cpp
parentCompute Aspect Ratio (diff)
downloadcst116-lab1-edwardfine-cba5229fd833e88dda2cf0e6f1947923bee8fe12.tar.xz
cst116-lab1-edwardfine-cba5229fd833e88dda2cf0e6f1947923bee8fe12.zip
Check aspect ratio and print a message if it's too big.
Diffstat (limited to 'BlankConsoleLab/CST116-Lab1-Fine.cpp')
-rw-r--r--BlankConsoleLab/CST116-Lab1-Fine.cpp38
1 files changed, 25 insertions, 13 deletions
diff --git a/BlankConsoleLab/CST116-Lab1-Fine.cpp b/BlankConsoleLab/CST116-Lab1-Fine.cpp
index b37b273..a705e95 100644
--- a/BlankConsoleLab/CST116-Lab1-Fine.cpp
+++ b/BlankConsoleLab/CST116-Lab1-Fine.cpp
@@ -18,20 +18,32 @@ int main()
int correct = 0;
float area;
float aspectRatio;
- while (correct == 0) {
- cout << "How long is your kite in centimeters? ";
- cin >> length;
- cout << endl << "How wide is your kite in centimeters? ";
- cin >> width;
- cout << endl << "Your kite is " << length << "cm long and " << width << "cm wide? 1=Yes/ 0=No ";
- cin >> correct;
- cout << endl;
+ int goodRatio = 0;
+ while (goodRatio == 0) {
+ while (correct == 0) {
+ cout << "How long is your kite in centimeters? ";
+ cin >> length;
+ cout << endl << "How wide is your kite in centimeters? ";
+ cin >> width;
+ cout << endl << "Your kite is " << length << "cm long and " << width << "cm wide? 1=Yes/ 0=No ";
+ cin >> correct;
+ cout << endl;
+ }
+ cout << "Calculating area in square meters..." << endl;
+ area = (length * width) / 2.0;
+ area = area / 10000;
+ cout << "Your Kite's area is " << area << "meters squared." << endl;
+ aspectRatio = (width / length);
+ if (aspectRatio >= 1) {
+ cout << "*Warning* You have a low aspect ratio of " << aspectRatio<< ". A lower aspect ratio would provide better stability for your kite, try haing a smaller width." << endl;
+ correct = 0;
+ }
+ else {
+ goodRatio = 1;
+ cout << "You have a good aspect ratio of " << aspectRatio << endl;
+ }
}
- cout << "Calculating area in square meters..." << endl;
- area = (length * width) / 2.0;
- area = area / 10000;
- cout << "Your Kite's area is " << area << "meters squared.";
- aspectRatio = (width / length);
+