Hello guys, can you help me, please.

I need to make a program that preserving the order of the words, invert the order of the letters of a word yes and the other one of a phrase. For this use only one stack. Example:

original string:
TODAY THE SUN IS BEAUTIFUL

program result:
YADOT THE NUS IS LUFITUAEB