diff options
| author | Musa Ahmed <[email protected]> | 2022-10-19 13:14:46 -0700 |
|---|---|---|
| committer | Musa Ahmed <[email protected]> | 2022-10-19 13:14:46 -0700 |
| commit | bf03a6be0f11b26ea528378afe162bc17f502fe4 (patch) | |
| tree | 43b62860abb62d22d5718ff6a0810ddbf22ac62f | |
| parent | finished part 1 (diff) | |
| download | cst116-lab1-m005a-bf03a6be0f11b26ea528378afe162bc17f502fe4.tar.xz cst116-lab1-m005a-bf03a6be0f11b26ea528378afe162bc17f502fe4.zip | |
Limited input to between 1 and 400 for width & lenght
| -rw-r--r-- | BlankConsoleLab/BlankConsoleLab.cpp | 42 |
1 files changed, 36 insertions, 6 deletions
diff --git a/BlankConsoleLab/BlankConsoleLab.cpp b/BlankConsoleLab/BlankConsoleLab.cpp index 15b9b78..173f464 100644 --- a/BlankConsoleLab/BlankConsoleLab.cpp +++ b/BlankConsoleLab/BlankConsoleLab.cpp @@ -14,20 +14,36 @@ int main() float width; float length; float area; + float mass; float aspect_ratio; + float grav_pull; bool isStable = false; + bool range = false; while (isStable == false) { // prompt user for width and length input, then store into appropriate variables - cout << "Enter width (In centimeters): " << endl; - cin >> width; - cout << "Enter length (In centimeters): " << endl; - cin >> length; + while (range == false) { + + cout << "Enter width (In centimeters): " << endl; + cin >> width; + cout << "Enter length (In centimeters): " << endl; + cin >> length; + // loops only if the width and length are not between 1 and 400 + if (width > 400 || length > 400 || width < 1 || length < 1) { + cout << "Please keep the width and length between 1 and 400 centimeters" << endl; + } + + else { + range = true; + break; + } + } + // display the entered values back to the user - cout << "You entered: " << width << "cm for width, and: " << length << "cm for length" << endl; + cout << "You entered: " << width << " cm for width, and: " << length << " cm for length" << endl; // compute and siplay the area area = ((width * length) / 2) / 10000; @@ -36,17 +52,31 @@ int main() //computer the aspect ratio and prompt user with warning if condition not met aspect_ratio = (width / length); + //compute the mass of the kite by multiplying the area, fabric weight, and converting to kg + mass = (area * 135) / 1000; + cout << "The mass of your kite is: " << mass << " kg" << endl; + + //compute the gravitional pull of the kite by multiplying th emass by the acceleration due to gravity + grav_pull = mass * 9.8; + cout << "The gravitional pull of your kite is: " << grav_pull << " Newtons" << endl; + //Warns if aspect ratio is too high and causes instability if (aspect_ratio >= 1) { - cout << "Warning, an aspect ratio of :" << aspect_ratio << " is too high and will provide instability" << endl; + cout << "Warning, an aspect ratio of: " << aspect_ratio << " is too high and will provide instability" << endl; + range = false; } // otherwise break out successfully else { cout << "Aspect Ratio: " << aspect_ratio << endl; + isStable = true; break; } + + + } + } |