The Corpus of Contemporary American EnglishCorpus of Contemporary American English has 2151 cites for "the way in which" and the British National CorpusBritish National Corpus has 2574. For "the ways in which", the figures are 2127 and 788. To put that into perspective, both corpora combined barely have 200 cites for "black car".
This goes to show that "the way(s) in which" is not only perfectly grammatical and idiomatic, but also extremely common. So the rule from your book is complete and utter nonsense.
Of course there will always be particular situations in which the phrase is not idiomatic, or even ungrammatical, but then again the same applies to "black car". That is something that has to be decided on a case-by-case basis. As several commenters have pointed out already, the first two of your three example sentences indeed do not work. But the third one actually does. The difference being that in the former two, "the way" is equivalent to "how", while in the last one, "the two ways" refers to two actual mechanisms.