#include <iostream>
using namespace std;
static const double LIGHT_SPEED = 299792458;
int main()
{
double m;
cout << "Enter a mass in kilograms: ";
cin >> m;
if (m < 0)
{
cout << "Mass can't be negative." << endl;
return -1;
}
double E = m * LIGHT_SPEED * LIGHT_SPEED;
cout.precision(3);
cout << "The energy is " << E << " joules." << endl;
return 0;
}
Comments