/* energy1.cpp computes energy from a given mass using
 * Einstein's mass-to-energy conversion equation.
 *
 * Input:        The mass (in kilograms) being converted to energy
 * Precondition: mass >= 0
 * Output:       The amount of energy (in kilojoules) corresponding
 *                  to mass
 ********************************************************************/

#include <iostream.h>                          // cin, cout, <<, >>
#include <assert.h>                            // assert()
#include <math.h>                              // pow()

int main()
{
	const double SPEED_OF_LIGHT = 2.997925e8;  // meters/sec

	cout << "To find the amount of energy obtained from a given mass,\n"
           "enter a mass (in kilograms): ";
   double mass;
   cin >> mass;                               // get mass
	assert(mass >= 0);                         // make sure its 
nonnegative 
                                              // compute energy
   double energy = mass * pow(SPEED_OF_LIGHT, 2);
                                              // display energy
	cout << mass << " kilograms of matter will release " 
        << energy << " kilojoules of energy.\n";
   return 0;
}


