Write a C++ program to calculate relativistic kinetic energy (K), when the mass (m) is given by the user. The given below is the equation to calculate the relativistic kinetic energy.
m = mass, v = 1500 ms-1 (speed of the moving object), and c = 12000 ms-1(speed of light)
Sample Output
Enter a mass of the moving objects (m): 60
60 8.7083e+09
59 8.56316e+09
58 8.41802e+09
57 8.27289e+09
56 8.12775e+09
#include <iostream>
using std::cin;
using std::cout;
using std::pow;
using std::endl;
int main()
{
// relativistic kinetic energy
// EK = (gamma -1)*m*c^2;
// where gamma = 1\(1-v^2/c^2)^0.5
// by the terms of the problem c =12000 v=1500
const float c = 12000.0;
const float v = 1500.0;
float m;
float ratio;
cout << "Enter a mass of the moving objects (m): ";
cin >> m;
if (m < 50 || m>100) {
cout << "Incorrect data entered";
return -1;
}
ratio = (1 / pow((1 - (v * v) / (c * c)), 2)-1) * m * c * c;
for (float i = m; i > 39; i--) {
cout << i << " " << i * ratio<<endl;
}
}
Comments
Leave a comment