Let xxx be the number of books bought online and yyy be the number bought in the store. We are told:

  1. Total books:

x+y=240x+y=240x+y=240

  1. Total money collected:

18x+22.5y=499518x+22.5y=499518x+22.5y=4995

From the first equation, express yyy in terms of xxx:

y=240−xy=240-xy=240−x

Substitute into the second equation:

18x+22.5(240−x)=499518x+22.5(240-x)=499518x+22.5(240−x)=4995

18x+5400−22.5x=499518x+5400-22.5x=499518x+5400−22.5x=4995

−4.5x+5400=4995-4.5x+5400=4995−4.5x+5400=4995

−4.5x=4995−5400=−405-4.5x=4995-5400=-405−4.5x=4995−5400=−405

x=−405−4.5=90x=\frac{-405}{-4.5}=90x=−4.5−405​=90

Then find yyy:

y=240−90=150y=240-90=150y=240−90=150

So:

  • 90 books were bought online.
  • 150 books were bought at the store.