8.4 - 5 = 4.4v drop
4.4 * 0.4 = 1.76W to dissipate
Same math goes for the second regulator (surely some simple arithmetic shouldn't be too much trouble).
You'll want the die to be well under 100C, to be on the safe side. Pessimistically, one could take around 40C ambient temperature. This means you'll want, if possible, to keep the temperature rise within 60C or so, for the power you need to dissipate.
You haven't mentioned which package the NCP1117 will be. If you look on page 2 of the datasheet, you'll see the thermal resistances are vastly different between the two.