Write your question here.
I have this mostly figured out, but I do not know why it's not letting me execute the equation when I type it in and give me the output needed. What else do I need to add?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main()
{
double mass;
double velocity;
double momentum;
double kenergy;
cout << "How much mass:";
cin >> mass;
cout << "How much velocity:";
cin >> velocity;
momentum = mass * velocity;
kenergy = kinetic(mass, velocity);
return 0;
}
|
The problem given is:
You will need to include the iomanip library, as well as the iostream library, for this problem.
In classical physics:
momentum is mass times velocity ( m * v )
kinetic energy is one half the mass times the square of the velocity ( m * v2 / 2 )
Prompts the user for the mass and the velocity as input.
Use double variables.
Then compute the momentum and kinetic energy.
Print the momentum and the kinetic energy with identifying text.
The execution result should have six lines 1) input mass, 2) input velocity, 3) output mass, 4) output velocity, 5) momentum, 6) kinetic energy.
Round the printed values to two decimal positions and align the decimal points.
Test data, run the program twice:
First test input 5.0 kilograms and 4.0 meters per second
Second test input 3.15 kilograms and 10.0 meters per second
Note: With the input in kilograms and meters per second, the units for the momentum is Kg m/s and for Kinetic energy is Joules.