Program 4.5: The energy equivalent of the mass of an electron

Program 4.5 calculates the energy equivalent of an electron using Einstein's famous formula E = mc2.

class mc2 {
  public static void main (String args[]) {

    double mass = 9.1096E-25;
    double c = 2.998E8;
    double E = mass * c * c;
    System.out.println(E);
  }
}
Here's the output:


% javac mc2.java
% java mc2
8.18771e-08
%

Copyright 1996 Elliotte Rusty Harold
elharo@sunsite.unc.edu
This Chapter
Examples
Home