From 4f66a88ab2680364cd7d2e8577c382ee89574928 Mon Sep 17 00:00:00 2001 From: Batbold74 <114635352+Batbold74@users.noreply.github.com> Date: Thu, 20 Oct 2022 18:02:06 -0700 Subject: Add files via upload Hi. Here is my Lab1. Thank you. --- CST116-Lab1-Bold.cpp | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 CST116-Lab1-Bold.cpp diff --git a/CST116-Lab1-Bold.cpp b/CST116-Lab1-Bold.cpp new file mode 100644 index 0000000..4b9c4ba --- /dev/null +++ b/CST116-Lab1-Bold.cpp @@ -0,0 +1,49 @@ +#include + +using namespace std; + +using std::cout; +using std::cin; +using std::endl; + +int main() +{ + float width = 0; + float length = 0; + float area = 0; + float aspect_ratio = 0; + const float fabric = 135; // 135 gram per meter + float grav = 0; // gravitation + + while (width < 1 || width > 400) //I used while for the range of 1 to 400 + { + cout << "Enter the width in centimeters between 1 and 400 : "; + cin >> width; + + } + + while (length < 1 || length > 400) //I used while for the length range as well. It will loop untill correct number entered. + { + cout << "Enter the length in centimeters between 1 and 400 : "; + cin >> length; + + } + + cout << "\n\nYour width is " << width << " and " << "length is " << length << " centimeters.\n\n"; + + area = (((width * length) / 2) / 10000); //Calculating total area here. + grav = area * fabric; //Calculating gravitational pull. + + aspect_ratio = width / length; //Calcualting the aspect of ratio + + cout << "Total area: " << area << " square meters." <<"\nGravitational pull: " << grav <<" gr.\n"; + cout << "The aspect ratio: " << aspect_ratio; + + if (aspect_ratio >= 1) // I used if statement + cout << "\nA lower aspect ratio provides more stability. \n\n"; + + else cout << "\nThe aspect of ratio is good. \n\n"; + + return 0; +} + -- cgit v1.2.3