diff options
Diffstat (limited to 'ee1301/wk6/lab5/momentum.cpp')
-rw-r--r-- | ee1301/wk6/lab5/momentum.cpp | 54 |
1 files changed, 27 insertions, 27 deletions
diff --git a/ee1301/wk6/lab5/momentum.cpp b/ee1301/wk6/lab5/momentum.cpp index a49be54..dfbaeee 100644 --- a/ee1301/wk6/lab5/momentum.cpp +++ b/ee1301/wk6/lab5/momentum.cpp @@ -1,28 +1,28 @@ -#include <iostream> - -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; +#include <iostream>
+
+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 |