What do I need to destroy the world? The gravitational binding energy of a planet is the amount of energy required to separate every tiny piece of it so that no piece will orbit or collide with another piece. For a uniform sphere, Wikipedia gives this formula:

$$E = \frac{3GM^2}{5R}$$

Where G is the gravitational constant (6.672e-11 m3•kg-1•s-2), M is mass, and R is the radius.

I could make this challenge about merely calculating this in Joules (kg•m2•s-2), but… that would be boring. And besides, not everyone understands Joules.

So instead, let's convert it into the following units:


Kilotons of TNT (4.184 trillion Joules, shorthand kilotons)
Hiroshima nuclear weapons (62.76 trillion Joules, shorthand nukes)
Hostess&trade; Twinkies (560,000 Joules, shorthand twinkies)
Kilowatt-hours (exactly 3.6 million Joules, shorthand kWh)
Kilograms of mass-energy (1 kg mass-energy = 299,792,4582 Joules, shorthand kg)


So, take in the following input:


mass in kilograms
radius in meters
one of six distinct inputs representing the unit to use


And output the binding energy in the specified units. Append the shorthand unit to the end of the output.

Rules


The shorthand for Joules is J.
Arbitrary whitespace is allowed, as long as it doesn't split the shorthand unit or the number.
Scientific notation is allowed, in whatever format your language uses.
You only need 4 significant figures. Floating points are highly recommended.
Blah blah shortest answer in bytes.


Test Cases

Generated with this spreadsheet.

Mass (kg)   Radius (m)  J           kilotons    nukes       twinkies    kWh         kg
3.302E+23   2440000     1.789E+30   4.275E+17   2.850E+16   3.194E+24   4.969E+23   1.990E+13
4.869E+24   6052000     1.568E+32   3.748E+19   2.499E+18   2.800E+26   4.356E+25   1.745E+15
5.974E+24   6371000     2.242E+32   5.360E+19   3.573E+18   4.004E+26   6.229E+25   2.495E+15
6.419E+23   3390000     4.866E+30   1.163E+18   7.753E+16   8.689E+24   1.352E+24   5.414E+13
1.899E+27   69911000    2.065E+36   4.935E+23   3.290E+22   3.687E+30   5.736E+29   2.298E+19
5.685E+26   58232000    2.222E+35   5.310E+22   3.540E+21   3.968E+29   6.172E+28   2.472E+18
8.683E+25   25360000    1.190E+34   2.845E+21   1.896E+20   2.125E+28   3.306E+27   1.324E+17
1.024E+26   24620000    1.705E+34   4.075E+21   2.717E+20   3.045E+28   4.736E+27   1.897E+17
1.311E+22   1186000     5.801E+27   1.387E+15   9.244E+13   1.036E+22   1.611E+21   6.455E+10
1.989E+30   696300000   2.274E+41   5.436E+28   3.624E+27   4.062E+35   6.318E+34   2.531E+24
7.350E+22   1737000     1.245E+29   2.976E+16   1.984E+15   2.223E+23   3.458E+22   1.385E+12




Inspired by Powering the Death Star with Twinkies by Scott Manley.
JavaScript (ES6), 78 bytes

Takes input as 3 distinct variables (mass, radius, unit).

(m,r,u)=&gt;m*m/r/[8987e9,56,6276e6,,4184e5,1e-4,360][parseInt(u,30)%7]/2498e11+u


Test cases

The following snippet runs all test cases in the provided spreadsheet.



let f=

(m,r,u)=&gt;m*m/r/[8987e9,56,6276e6,,4184e5,1e-4,360][parseInt(u,30)%7]/2498e11+u

console.log(
  [
    '3.302e+23 2440000   1.789e+30 4.275e+17 2.850e+16 3.194e+24 4.969e+23 1.990e+13',
    '4.869e+24 6052000   1.568e+32 3.748e+19 2.499e+18 2.800e+26 4.356e+25 1.745e+15',
    '5.974e+24 6371000   2.242e+32 5.360e+19 3.573e+18 4.004e+26 6.229e+25 2.495e+15',
    '6.419e+23 3390000   4.866e+30 1.163e+18 7.753e+16 8.689e+24 1.352e+24 5.414e+13',
    '1.899e+27 69911000  2.065e+36 4.935e+23 3.290e+22 3.687e+30 5.736e+29 2.298e+19',
    '5.685e+26 58232000  2.222e+35 5.310e+22 3.540e+21 3.968e+29 6.172e+28 2.472e+18',
    '8.683e+25 25360000  1.190e+34 2.845e+21 1.896e+20 2.125e+28 3.306e+27 1.324e+17',
    '1.024e+26 24620000  1.705e+34 4.075e+21 2.717e+20 3.045e+28 4.736e+27 1.897e+17',
    '1.311e+22 1186000   5.801e+27 1.387e+15 9.244e+13 1.036e+22 1.611e+21 6.455e+10',
    '1.989e+30 696300000 2.274e+41 5.436e+28 3.624e+27 4.062e+35 6.318e+34 2.531e+24',
    '7.350e+22 1737000   1.245e+29 2.976e+16 1.984e+15 2.223e+23 3.458e+22 1.385e+12'
  ]
  .map((l, n) =&gt; {
    [m, r, ...res] = l.match(/\S+/g).map(Number);

    return 'Test case #' + -~n + ' -&gt; ' + (
      ['J', 'kilotons', 'nukes', 'twinkies', 'kWh', 'kg']
      .every((u, i) =&gt; +(+f(m, r, u).split(u).join``).toExponential(3) === +res[i])
      ? 'OK' : 'FAIL'
    )
  })
)




How?

This is quite similar to @ColeraSu's C answer, with a JS-friendly hash function that works on the whole unit string.

Unit       | Parsed as (*) | Base-30 -&gt; Dec. | mod 7
-----------+---------------+-----------------+------
"J"        | "j"           | 19              | 5        (*):
"kilotons" | "kilotons"    | 451052545318    | 4          Because we're parsing as Base-30,
"nukes"    | "n"           | 23              | 2          characters [u-z] (and anything
"twinkies" | "t"           | 29              | 1          after them) are simply ignored.
"kWh"      | "k"           | 20              | 6
"kg"       | "kg"          | 616             | 0