My teacher has assigned a program to use both if-else statements and switch statements, so we understand how to implement both. The program asked u
Unless you have an absolutely ghastly compiler extension, you can't switch on a range in C++.
But you could use a switch elegantly if you create a std::vector of the BMI ranges:
std::vector
Then use std::lower_bound along with std::distance to get the position of a given BMI in the above ranges. This is the quantity that you switch on.
You could then go one stage further and define a std::vector of the output messages. Then you need neither a switch nor an if block! All the selection logic is delegated to std::lower_bound.
I deliberately haven't given you the full code: I trust these hints are sufficient.