diff options
| author | Batbold74 <[email protected]> | 2022-10-20 18:02:06 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-10-20 18:02:06 -0700 |
| commit | 4f66a88ab2680364cd7d2e8577c382ee89574928 (patch) | |
| tree | ed287be0d63956a6455b33a14134d7525d5b6066 /CST116-Lab1-Bold.cpp | |
| parent | I don't know why I can't delete. So, it is a test. (diff) | |
| download | cst116-lab1-batbold74-master.tar.xz cst116-lab1-batbold74-master.zip | |
Hi. Here is my Lab1. Thank you.
Diffstat (limited to 'CST116-Lab1-Bold.cpp')
| -rw-r--r-- | CST116-Lab1-Bold.cpp | 49 |
1 files changed, 49 insertions, 0 deletions
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 <iostream>
+
+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;
+}
+
|