Answer to Question #188127 in C++ for Tharindu

Question #188127

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)

  • User may insert the mass of the moving objects (m) above or equal to 50 kg and below 100 kg as the highest mass.
  • Consider the speed of light (c) as a constant value.
  • Then the program should calculate the relativistic kinetic energy (K) for each mass of the moving object until the mass becomes 39 kg.
  • Use the necessary header files to do the calculation.

 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



1
Expert's answer
2021-05-02T08:35:55-0400
#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;
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS