From d4ef70a780d293bf32a8d08152ee590cd8ed95e0 Mon Sep 17 00:00:00 2001 From: JonCr Date: Fri, 21 Oct 2022 01:32:16 -0700 Subject: Update --- BlankConsoleLab/BlankConsoleLab.cpp | 84 ++++++++++++++++++++++--------------- 1 file 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 -#include 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 -- cgit v1.2.3