Luis bought eight bags of candy at the store for a total price of $21.54. He bought some bags of candy that cost $2.22 each and the rest cost $3.48 each. How many bags of the $3.48 candy did Luis buy?

A=2.22

B=3.48

A + B = 8
2.22A x 3.48B = 21.54

solve for B

C means cheap candy bag, E means expensive candy bag.

C*2.22+E*3.48=21.54
C+E=8

I got this far, but how do I solve for B?

To solve this problem, let's assign variables to the unknown quantities. Let's say the number of bags of $2.22 candy is x, and the number of bags of $3.48 candy is y.

We know that Luis bought a total of 8 bags of candy, so we can write the first equation: x + y = 8.

We also know that the total price of the candy is $21.54. The cost of each $2.22 bag of candy is $2.22 * x, and the cost of each $3.48 bag of candy is $3.48 * y. The total price equation is: $2.22 * x + $3.48 * y = $21.54.

Now we can solve this system of equations. We can start by solving the first equation for x: x = 8 - y.

Now substitute this expression for x in the second equation: $2.22 * (8 - y) + $3.48 * y = $21.54.

Simplify the equation: $17.76 - $2.22y + $3.48y = $21.54.

Combine like terms: $1.26y = $3.78.

Divide both sides of the equation by $1.26: y = 3.

Therefore, Luis bought 3 bags of candy that cost $3.48 each.