A recipe requires ingredients in the ratio of 3:4:5 for sugar, flour, and butter respectively. If the total weight of the ingredients used is 240 grams, how many grams of each ingredient are needed? Let's think step by step and output the final answer within \boxed{}.
user