Answer:
112 dollars
Step-by-step explanation:
The best in this type of problem is to start from what we have, that is 12 dollars.
He had 12 dollars left after spending 1/2 in the bookstore, so before that would be 12 / (1/2) = 24 dollars.
Before that he spent 1/2 on gifts, then it would be 24 / (1/2) = 48 dollars he had before buying the gifts.
The first thing he did was spend his money in the supermarket therefore, it would be 48 / (3/7) = 112 dollars, that means that at the beginning he had 112 dollars.
We checked: at the supermarket 112 * (3/7) = 48 dollars
in gifts 48 * (1/2) = 24 dollars
and in the library 24 * (1/2) = 12 dollars