summaryrefslogtreecommitdiff
path: root/BlankConsoleLab/CST116-Lab1-Hill.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'BlankConsoleLab/CST116-Lab1-Hill.cpp')
-rw-r--r--BlankConsoleLab/CST116-Lab1-Hill.cpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/BlankConsoleLab/CST116-Lab1-Hill.cpp b/BlankConsoleLab/CST116-Lab1-Hill.cpp
new file mode 100644
index 0000000..0f07f62
--- /dev/null
+++ b/BlankConsoleLab/CST116-Lab1-Hill.cpp
@@ -0,0 +1,52 @@
+#include <iostream>
+
+using std::cout;
+using std::cin;
+using std::endl;
+
+float width, length;
+
+
+int main()
+{
+ cout << std::fixed;
+ cout.precision(3);
+
+ cout << "Please enter the width of your kite in centimeters. Use values between 1 - 400 cm." << endl;
+
+ do {
+
+ cin >> width;
+ if (width < 1 || width > 400) cout << "Please try again with a value between 1 - 400" << endl;
+
+ } while ( width > 400 || width < 1);
+
+ cout << "Now enter the length, again between 1 - 400cm." << endl;
+
+ do {
+
+ cin >> length;
+ if (length < 1 || length > 400) cout << "Please try again with a value between 1 - 400" << endl;
+
+ } while (length > 400 || length < 1);
+
+ cout << endl << "The dimensions of your kite are " << width << "cm by " << length << "cm." << endl;
+
+ double area = (width * length) / 10000.0;
+ float aspectRatio = width / length;
+
+ cout << "The area is " << area << " square meters." << endl;
+ cout << "The aspect ratio is " << width / length << endl;
+
+ if (aspectRatio >= 1) {
+ cout << endl << "WARNING: A lower aspect ratio might provide better stability." << endl;
+ }
+
+ const float mass = 135.0f * area;
+ double forceGravity = 9.8 * mass;
+
+ cout << endl << "Your kite has a mass of " << mass << " grams." << endl
+ << "The kite is experiencing a gravitational force of " << forceGravity << " newtons." << endl;
+
+}
+