summaryrefslogtreecommitdiff
path: root/BlankConsoleLab/BlankConsoleLab.cpp
diff options
context:
space:
mode:
authorJonCr <[email protected]>2022-10-21 01:32:16 -0700
committerJonCr <[email protected]>2022-10-21 01:32:16 -0700
commitd4ef70a780d293bf32a8d08152ee590cd8ed95e0 (patch)
treed326c7e213ca2b08f453a827f42714ce6861c39e /BlankConsoleLab/BlankConsoleLab.cpp
parentUpdate (diff)
downloadcst116-lab1-cognitiveshadow-d4ef70a780d293bf32a8d08152ee590cd8ed95e0.tar.xz
cst116-lab1-cognitiveshadow-d4ef70a780d293bf32a8d08152ee590cd8ed95e0.zip
Update
Diffstat (limited to 'BlankConsoleLab/BlankConsoleLab.cpp')
-rw-r--r--BlankConsoleLab/BlankConsoleLab.cpp84
1 files changed, 51 insertions, 33 deletions
diff --git a/BlankConsoleLab/BlankConsoleLab.cpp b/BlankConsoleLab/BlankConsoleLab.cpp
index cec5902..7297143 100644
--- a/BlankConsoleLab/BlankConsoleLab.cpp
+++ b/BlankConsoleLab/BlankConsoleLab.cpp
@@ -2,7 +2,6 @@
//
#include <iostream>
-#include <iomanip>
using namespace std;
@@ -12,7 +11,10 @@ using std::endl;
float GetLength();
float GetWidth();
-//void CalcArea(float length, float width);
+void CalcAR(float length, float width);
+float CalcArea(float length, float width);
+float CalcMass(float area);
+void CalcGP(float mass);
int main()
{
@@ -21,39 +23,22 @@ int main()
float area = 0;
float aspectRatio = 0;
float mass = 0;
- const int fabricWeight = 135;
- float gravitationalPull = 0;
+ // Get measurements
length = GetLength();
width = GetWidth();
- //CalcArea(length, width);
-
-
- cout << endl << endl << "Length: " << length << endl;
- cout << "Width: " << width << endl;
- area = (width * length) / 2;
- area = area / 10000;
+ // Calculate aspect ratio
+ CalcAR(length, width);
- cout << endl << "The area of you kite is " << area << " square meters." << endl;
-
+ // Calculate area
+ area = CalcArea(length, width);
- aspectRatio = width / length;
+ // Calculate mass
+ mass = CalcMass(area);
- cout << "Your kite's aspect ratio is: " << aspectRatio << endl;
-
- if (aspectRatio > 1)
- {
- cout << endl << "WARNING: Aspect ratio is too high. A lower aspect ratio will provide greater stability. Consider increasing the kite's aspect ratio." << endl;
- }
-
- mass = (area * fabricWeight) / 1000;
-
- cout << endl << "Your kite weighs " << mass << " kg.";
-
- gravitationalPull = mass * 9.8;
-
- cout << endl << "The gravitational pull on your kite is " << gravitationalPull << " N/kg" << endl;
+ // Calculate gravitational pull
+ CalcGP(mass);
return 0;
}
@@ -64,12 +49,14 @@ float GetLength()
cout << "Enter kite length in centimeters: ";
cin >> length;
+ // Set max length to 400
while (length > 400)
{
cout << "Length is too large. Must be less than 400." << endl;
cout << "Enter kite length in centimeters: ";
cin >> length;
}
+ // Set min length to 1
while (length < 1)
{
cout << "Length is too small. Must be greater than 1." << endl;
@@ -86,12 +73,14 @@ float GetWidth()
cout << "Enter kite width in centimeters: ";
cin >> width;
+ // Set max width to 400
while (width > 400)
{
cout << "Width is too large. Must be less than 400." << endl;
cout << "Enter kite width in centimeters: ";
cin >> width;
}
+ // Set min width to 1
while (width < 1)
{
cout << "Width is too small. Must be greater than 1." << endl;
@@ -101,14 +90,25 @@ float GetWidth()
return width;
}
-/*
-float CalcArea(float length, float width)
+void CalcAR(float length, float width)
{
- float area;
+ float aspectRatio = width / length;
- cout << endl << endl << "Length: " << length << endl;
+ cout << endl << "Length: " << length << endl;
cout << "Width: " << width << endl;
+ cout << endl << "Your kite's aspect ratio is: " << aspectRatio << endl;
+
+ // Print warning
+ if (aspectRatio > 1)
+ {
+ cout << endl << "WARNING: Aspect ratio is too high. A lower aspect ratio will provide greater stability. Consider increasing the kite's aspect ratio." << endl;
+ }
+}
+float CalcArea(float length, float width)
+{
+ float area;
+
area = (width * length) / 2;
area = area / 10000;
@@ -116,4 +116,22 @@ float CalcArea(float length, float width)
return area;
}
-*/
+float CalcMass(float area)
+{
+ float mass;
+ const int fabricWeight = 135;
+
+ mass = (area * fabricWeight) / 1000;
+
+ cout << endl << "Your kite weighs " << mass << " kg." << endl;
+
+ return mass;
+}
+void CalcGP(float mass)
+{
+ float gravitationalPull;
+
+ gravitationalPull = mass * 9.8;
+
+ cout << endl << "The gravitational pull on your kite is " << gravitationalPull << " N/kg" << endl;
+} \ No newline at end of file