summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorprestonderek <[email protected]>2022-10-19 20:39:27 -0700
committerprestonderek <[email protected]>2022-10-19 20:39:27 -0700
commit491a296dca6d75c7c4bfdd4df666292c2ef80095 (patch)
treef477e61a14f34763303b7326fa9e59f475e9d8cb
parentCommit for part 1 complete (diff)
downloadcst116-lab1-prestonderek-491a296dca6d75c7c4bfdd4df666292c2ef80095.tar.xz
cst116-lab1-prestonderek-491a296dca6d75c7c4bfdd4df666292c2ef80095.zip
Commit for Part 2 complete
-rw-r--r--BlankConsoleLab/BlankConsoleLab.cpp49
-rw-r--r--BlankConsoleLab/CST116-Lab1-Pseudocode-Preston.txt60
2 files changed, 104 insertions, 5 deletions
diff --git a/BlankConsoleLab/BlankConsoleLab.cpp b/BlankConsoleLab/BlankConsoleLab.cpp
index e80106c..db75a93 100644
--- a/BlankConsoleLab/BlankConsoleLab.cpp
+++ b/BlankConsoleLab/BlankConsoleLab.cpp
@@ -1,7 +1,8 @@
// BlankConsoleLab.cpp : This file contains the 'main' function. Program execution begins and ends there.
-//
+//Changes are being made 10/19 for PART 2
#include <iostream>
+#include <iomanip>
using std::cout;
using std::cin;
@@ -14,24 +15,64 @@ int main()
float areaCM;
float areaM;
float ratio;
+ float totalMass;
+ float kiteGravPull;
+ //for the input while loops
+ const int botnum = 1;
+ const int topnum = 400;
+
+ const int FabricWeight = 135;
+ const float pull = 9.8;
+
cout << "Please enter the length of your kite." << endl;
cin >> length;
+ //while length is out of bounds
+ while (length < botnum || length > topnum)
+ {
+ cout << "Please enter a value for length between 1 and 400." << endl;
+ cin >> length;
+ }
+
cout << "\nPlease enter the width of your kite." << endl;
cin >> width;
+
+ //while width is out of bounds
+ while (width < botnum || width > topnum)
+ {
+ cout << "Please enter a value for length between 1 and 400." << endl;
+ cin >> width;
+ }
+ cout << "Your kite has a length of: " << length << "cm, and a width of: " << width << "cm." << endl;
cout << "\n";
+ //Mathmatics
areaCM = (width * length) / 2;
areaM = areaCM / 10000;
- ratio = width / length;
+ ratio = (float)width / (float)length;
+ totalMass = (areaM * FabricWeight) / 1000;
+ kiteGravPull = totalMass * pull;
+ //makes sure the floats are printed with 5 decimals
+ cout << std::setprecision(5);
+ cout << std::fixed;
+
+ cout << "Your kite has an aspect ratio of: " << ratio << endl;
+ cout << "\n";
+
+ //Aspect Ratio if statement
if (ratio >= 1)
{
- cout << "WARNING: A lower aspect ratio \nwill provide more stability!\n" << endl;
+ cout << "WARNING: A lower aspect ratio will provide more stability!\n" << endl;
}
+ else
+ cout << "Nice aspect ratio!" << endl;
- cout << "Your kite has an area of: " << areaM << " square meters" << endl;
+ //Output
+ cout << "\nYour kite has an area of: " << areaM << " square meters" << endl;
cout << "Your kite has an area of: " << areaCM << " square centimeters" << endl;
+ cout << "Your kite is " << totalMass << " grams." << endl;
+ cout << "Your kite has a gravitational pull of: " << kiteGravPull << endl;
}
diff --git a/BlankConsoleLab/CST116-Lab1-Pseudocode-Preston.txt b/BlankConsoleLab/CST116-Lab1-Pseudocode-Preston.txt
index c6ab8c4..a16fa47 100644
--- a/BlankConsoleLab/CST116-Lab1-Pseudocode-Preston.txt
+++ b/BlankConsoleLab/CST116-Lab1-Pseudocode-Preston.txt
@@ -1,4 +1,4 @@
-Agile notes and Pseudocode for Lab1
+Agile notes and Pseudocode for Lab1 Part 1
This program requires the following
@@ -19,6 +19,15 @@ Output:
Output is self documenting
Shows input with labels, then the output
+Part 2
+
+1. Edit the user input so that they can only enter widths and lengths between 1 and 400. It is ok to just
+keep asking them to enter it correctly.
+2. Compute the total mass of your kite:
+a. Create a constant to store the mass of your kite per square meter. In the formula below, it is
+referred to as mass. You may assume a medium weight fabric at about 135 Grams / Sq Meter .
+3. Compute the gravitational pull on your kite.
+
Pseudocode for part 1:
@@ -46,5 +55,54 @@ begin main function
print "your kite's area in square meters is: " areaM
+Pseudocode for part 2
+
+
+int width
+int length
+float areaCM
+float areaM
+int ratio
+float totalmass
+float kitegravpull
+
+const mass = 135
+const botnum = 1
+const topnum = 400
+const gravpull = 9.8
+
+begin main function
+
+ print "enter width of kite"
+ input width
+
+ while width < botnum OR width > topnum
+ print enter a number for width between 1 and 400
+ input width
+
+ print "enter length of kite"
+ input length
+
+ while length < botnum OR length > topnum
+ print enter a number for length between 1 and 400
+ input length
+
+ print "your kite has a width of: " width " and length of: " length
+
+ areaCM = width x length / 2
+ areaM = areaCM / 10000
+ ratio = width / length
+ totalmass = areaM * mass / 1000
+ kitegravpull = totalmass * gravpull
+
+
+ if ratio >= 1
+ "Warning, a lower aspect ratio would provide more stability"
+ else
+ "nice aspect ratio"
+
+ print "your kite's area in square meters is: " areaM
+ print "your kites mass is: " + totalmass
+ print "your kites gravitational pull is: " + kitegravpull
\ No newline at end of file