summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdwardFine <[email protected]>2022-10-19 09:50:42 -0700
committerEdwardFine <[email protected]>2022-10-19 09:50:42 -0700
commitef90dfd96e79c8c299946e4574b8b2c090516bf6 (patch)
tree6c9a9e03f87d0fc7fe075e09f46359bba482ab87
parentRevert "Calculate Gravitational pull and display it in console" (diff)
downloadcst116-lab1-edwardfine-ef90dfd96e79c8c299946e4574b8b2c090516bf6.tar.xz
cst116-lab1-edwardfine-ef90dfd96e79c8c299946e4574b8b2c090516bf6.zip
Create const for the gravPull calculationsHEADmaster
-rw-r--r--BlankConsoleLab/CST116-Lab1-Fine.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/BlankConsoleLab/CST116-Lab1-Fine.cpp b/BlankConsoleLab/CST116-Lab1-Fine.cpp
index 5937c04..83f1893 100644
--- a/BlankConsoleLab/CST116-Lab1-Fine.cpp
+++ b/BlankConsoleLab/CST116-Lab1-Fine.cpp
@@ -7,6 +7,9 @@ using namespace std;
float GetArea(float length, float width);
float getMass(float area);
+float getGrav(float mass);
+const int gravConst = 6674300;
+const int earthMass = 59720000;
const int massMeter = 135;
using std::cout;
using std::cin;
@@ -18,6 +21,7 @@ int main()
float width=0;
int correct = 0;
float area;
+ float gravPull;
float aspectRatio;
int goodRatio = 0;
float mass;
@@ -53,7 +57,9 @@ int main()
}
}
mass = getMass(area);
- cout << "You kite has a mass of " << mass << "grams." << endl;
+ cout << "You kite has a mass of " << mass << " kilograms." << endl;
+ gravPull = getGrav(mass);
+ cout << "Your kite has a gravitational pull to the Earth of " << gravPull << "N at 200 m in the sky." << endl;
}
float GetArea(float length, float width) {
float area = 0;
@@ -64,7 +70,12 @@ float GetArea(float length, float width) {
float getMass(float area) {
float mass = 0;
mass = area * massMeter;
+ mass = mass / 1000;
return mass;
+}float getGrav(float mass) {
+ float gravPull = 0;
+ gravPull = gravConst * ((mass * earthMass) / 200);
+ return gravPull;
}