John spends 380 dollars to buy the following two items sugar and salt, the amount is 100 bags, a bag of sugar is 2 dollars, a bag of salt is 5 dollars, how much did John bought each of it?

I dunno how to write the equation and helps pls

2 answers

let then number of sugar bags be x
then the number of salt bags is 100-x

now for the cost:
2x + 5(100-x) = 380
2x + 500 - 5x = 380
-3x = -120
x = 40

so he bought 40 bags of sugar and 60 bags of salt

or, using two variables

sugar bags --- x
salt bags ----- y

x + y = 100
2x + 5y = 380

multiply the first by 2
2x + 2y = 200
2x + 5y = 380
subtract them:
3x = 120
x = 40

sub back into the first
40+y = 100
y = 60
Thanks a lot bro