In the first period 18 books were non-fiction out of 40 books. In percentaje, we have that

and x is given by

that is, 18 non-fiction books correspond to 45% of 40 books.
With this result, we can expected that 45% of 100 students prefer non-fiction books. That is

that is, 45 students check out non fiction books.