The U.S. was justified in dropping both atomic bombs. Before the U.S. dropped the Atomic Bomb, they warned Japan of the consequences if they did not cooperate. Japan did not surrender and therefore allowing the U.S. to follow through with their proposal of mass destruction on Japan. This gave them the right to drop the bombs to end the war.
The U.S. had other options if they didn't drop the Atomic Bombs like Operation Downfall (The invasion of Japan). This option would put more U.S. soldiers at risk of death so the release of the bombs saved more U.S. soldiers. However the dropping of the bombs did get Japan to surrender and end WWII allowing the U.S. to meet their goal.