Question 878670
Group the books by subject. You have 3 groups. So think of these 3 groups as 3 books (bind them up with tape or something)


There are 3! = 3*2*1 = 6 ways to arrange these 3 "books".


-------------------------------------------------------


Within the physics subgroup, there are 5! = 5*4*3*2*1 = 120 ways to arrange this set of books.


In the chem subgroup, there are 3! = 6 ways to arrange these books.


In the math subgroup, there are 3! = 6 ways to arrange these books.


-------------------------------------------------------


Multiply out the combos: 6*120*6*6 = 25,920



There are 25,920 total ways to arrange the books keeping them together in the same subject.