Line sensor (5 ir sensors)

instead of following the code and turning

I presume that you mean "instead of following the line...".

Think about what "on the line" means, in terms of sensor output. If you put the sensor pins in an array, and read all 5 sensors ONCE on each pass through loop, and put the values in one variable, using bitSet(), it would be MUCH simpler to write your program.

You'd get a value like b00000 (or b11111) when the robot was on (or off) the line. It would be simple to determine whether b00000 or b11111 meant that all sensors were on the line.

Suppose that b11111 meant that all the sensors are on the line. What would b11110 mean? What would b11100 mean? What would b01111 mean? What would b00111 mean?

Obviously, the more 0s on one end means that you are farther from the line. The end with the 0s tells you which way to turn, to get back on the line.

There are only 32 possible values, so a switch statement with 32 cases would cover all possible values.

Now, clearly some of those values, while theoretically possible, are very unlikely. b10001 would mean that the edge sensors are on the line, but the center sensors are not. Very unlikely, so you can safely ignore some cases. A lot of them actually.