// BlankConsoleLab.cpp : This file contains the 'main' function. Program execution begins and ends there. // #include using namespace std; using std::cout; using std::cin; using std::endl; // Functions float GetLength(); float GetWidth(); void CalcAR(float length, float width); float CalcArea(float length, float width); float CalcMass(float area); void CalcGP(float mass); // Main code int main() { float length = 0; float width = 0; float area = 0; float aspectRatio = 0; float mass = 0; // Get measurements length = GetLength(); width = GetWidth(); // Calculate aspect ratio CalcAR(length, width); // Calculate area area = CalcArea(length, width); // Calculate mass mass = CalcMass(area); // Calculate gravitational pull CalcGP(mass); return 0; } float GetLength() { float length; 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; cout << "Enter kite length in centimeters: "; cin >> length; } return length; } float GetWidth() { float width; 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; cout << "Enter kite width in centimeters: "; cin >> width; } return width; } void CalcAR(float length, float width) { float aspectRatio = width / length; 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; cout << endl << "The area of you kite is " << area << " square meters." << endl; 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; } // Finished