When a sample of methyl salicylate weighing 5.287 grams is burned in excess oxygen, 12.24 grams of CO2 and 2.522 grams of H2O are formed. What is the empirical formula for oil of wintergreen?

I know the answer is C8H8O3, I just need help finding out how to solve the problem. Thanks for any help in advance.

(a) Convert the grams of CO2 to moles of CO2 by dividing grams of CO2 by the molar mass of CO2.

Moles of CO2 = moles of carbon, C. Multiply moles of C by 12.011g/mol to get grams of carbon in the sample.
(b) Find the moles of H2O in a similar way.
Moles of H = (2)(moles of H2O). To get grams of H, multiply moles of H times 1.00794 g/mol
(c) Grams of O in the sample = (grams of sample) - (grams H + grams H)
(d) Convert grams O to moles
(e) Divide moles C, moles H, and moles O by the smallest of the three. This will give you a ratio of three numbers. Multiply those numbers if needed to get three whole numbers. The three whole numbers are the three subscripts in the empirical formula.

Clarification: In the last step multiply the three numbers in the mole ratio by the same number. Select the smallest multiplier that will give a three whole number ratio. Tose three numbers are your subscripts.

To determine the empirical formula of oil of wintergreen (methyl salicylate), you need to follow these steps:

Step 1: Convert the given masses to moles.
To do this, use the molar masses of the compounds involved. The molar masses are as follows:
Molar mass of CO2 = 44.01 g/mol
Molar mass of H2O = 18.02 g/mol

Calculate the number of moles of CO2:
moles of CO2 = mass of CO2 / molar mass of CO2
moles of CO2 = 12.24 g / 44.01 g/mol

Calculate the number of moles of H2O:
moles of H2O = mass of H2O / molar mass of H2O
moles of H2O = 2.522 g / 18.02 g/mol

Step 2: Find the molar ratios.
Divide both moles of CO2 and H2O by the smaller of the two values to obtain a whole number ratio.

moles of CO2 / smaller value = 12.24 g / 44.01 g/mol / (smaller value / smaller value)
moles of CO2 / smaller value = 12.24 g / 44.01 g/mol / 0.140476

moles of H2O / smaller value = 2.522 g / 18.02 g/mol / (smaller value / smaller value)
moles of H2O / smaller value = 2.522 g / 18.02 g/mol / 0.140476

The smaller value is 0.140476, so dividing both by this value gives:

moles of CO2 = 87.1
moles of H2O = 18.0

Step 3: Convert the moles to the smallest whole-number ratio.
Divide both values by the smallest one to obtain the simplest whole-number ratio.

moles of CO2 / 18 = 87.1 / 18 ≈ 4.84 ≈ 5
moles of H2O / 18 = 18.0 / 18 = 1

The ratio becomes:

CO2: 5
H2O: 1

Step 4: Write the empirical formula.
Finally, write the empirical formula using the ratios:

C5H2O

However, to simplify the formula further, we can multiply all the subscripts by 2:

C5H2O × 2 = C10H4O2

Therefore, the empirical formula for oil of wintergreen (methyl salicylate) is C10H4O2.