summaryrefslogtreecommitdiff
path: root/BlankConsoleLab/BlankConsoleLab.cpp
diff options
context:
space:
mode:
authorMorgan Cyrus <[email protected]>2022-10-19 17:33:17 -0700
committerMorgan Cyrus <[email protected]>2022-10-19 17:33:17 -0700
commitcc8830ab8e58807329408985047bcf81f8598d57 (patch)
treecc732c148d8680754a4ad5a9ab77499c96c74b25 /BlankConsoleLab/BlankConsoleLab.cpp
parentEntered while loops for mandating input between 1 and 400 (diff)
downloadcst116-lab1-cyrus-cc8830ab8e58807329408985047bcf81f8598d57.tar.xz
cst116-lab1-cyrus-cc8830ab8e58807329408985047bcf81f8598d57.zip
Added function for calculating kite mass
Diffstat (limited to 'BlankConsoleLab/BlankConsoleLab.cpp')
-rw-r--r--BlankConsoleLab/BlankConsoleLab.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/BlankConsoleLab/BlankConsoleLab.cpp b/BlankConsoleLab/BlankConsoleLab.cpp
index e381995..62450bb 100644
--- a/BlankConsoleLab/BlankConsoleLab.cpp
+++ b/BlankConsoleLab/BlankConsoleLab.cpp
@@ -14,12 +14,14 @@ using std::endl;
float kiteCalc(float wid, float len);
float aspectCalc(float wid, float len);
+float massCalc(float areaVal);
int main()
{
float kiteWidth = 0;
float kiteLen = 0;
float kiteArea = 0;
+ float kiteMass = 0;
// get user input for kiteWidth. Value entered must be between 1 and 400 or it will loop and ask again.
while(kiteWidth < 1 || kiteWidth > 400)
@@ -35,7 +37,6 @@ int main()
cin >> kiteLen;
}
-
cout << "\nYou have entered " << kiteWidth << "cm for kite width, and " << kiteLen << "cm for kite length." << endl;
//calculate the area of the kite and store in kiteArea
@@ -44,6 +45,8 @@ int main()
//calculate the aspect ratio of the kite and spit out a message to the user if the aspect ratio is greater than or equal to 1
aspectCalc(kiteWidth, kiteLen);
+
+ kiteMass = massCalc(kiteArea);
}
float kiteCalc(float wid, float len)
@@ -75,3 +78,14 @@ float aspectCalc(float wid, float len)
}
}
+
+float massCalc(float areaVal)
+{
+ cout << "Calculating kite mass....\n";
+
+ // calculate the mass of the kite/square meter assuming fabric mass of 135 Grams/Square meter
+ float kiteAreaCalc = 135 / areaVal;
+
+ cout << "Kite mass: " << kiteAreaCalc << endl;
+ return kiteAreaCalc;
+} \ No newline at end of file