From 175721a63b426355274fa9e8063f762020ab8362 Mon Sep 17 00:00:00 2001 From: RossTheRoss Date: Thu, 30 Jan 2020 16:55:04 -0600 Subject: R E A R R A N G E --- OLD/ee1301/wk6/lab5/momentum.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 OLD/ee1301/wk6/lab5/momentum.cpp (limited to 'OLD/ee1301/wk6/lab5/momentum.cpp') diff --git a/OLD/ee1301/wk6/lab5/momentum.cpp b/OLD/ee1301/wk6/lab5/momentum.cpp new file mode 100644 index 0000000..dfbaeee --- /dev/null +++ b/OLD/ee1301/wk6/lab5/momentum.cpp @@ -0,0 +1,28 @@ +#include + +double momentum (double velocity, double mass); + +int main() { + double velocity[3]; + double mass; + std::cout << "Please enter velocity (x y z) [m/s]: "; + std::cin >> velocity[0] >> velocity[1] >> velocity [2]; + std::cout << "Please enter mass [kg]: "; + std::cin >> mass; + + double* vector; + vector = new double[3]; + std::cout << "Momentum: <"; + for (int i=0; i<=2; i++) { + vector[i]=momentum(velocity[i], mass); + std::cout << vector[i]; + if ((i<2)) + std::cout << ","; + } + delete[] vector; + std::cout << ">" << std::endl; +} + +double momentum(double velocity, double mass) { + return velocity * mass; +} \ No newline at end of file -- cgit v1.2.3