Obstacle Avoiding Robot using switch case

So I am kind of stuck I am fairly new to using Arduino coding and coding in general. I have recently learned a switch case method through Matlab and want to apply it to an obstacle avoiding robot. Basically looking for tips on how to get started.
A little overview of the project I have the ultrasonic sensor mounted on a micro servo that will basically be sweeping left and right or from 0 to 180 degrees. I then will have the robot itself powered by two continuous servo motors I'm thinking of having 3 cases.

First case: if the distance is greater towards the right the robot will stop the right wheel and supply power to the left wheel and move towards the right

Second case: if the distance is greater towards the left the robot will stop the left wheel and supply power to the right wheel only and move towards the left.

Third case: if the distance is greater towards the at 90 degrees (meaning straight ahead the robot will continue to move forward
In all honesty, I want to know if this is practical. Also, I am also confused about the wiring diagram on how to set the components to communicate with each other effectively. Any and all help will be appreciated.

It may well be a practical approach.

Try it.

Hint: sometimes, ultrasonic sensors don’t see obstacles if they are either soft or hard and angled so that they are likely to reflect an incident pulse away from the receiver.

Be prepared to fail.

If you want people to comment on the wiring you would need to give details of the components and how they are wired.

Initially run the robot slowly and pepper your code with print statements so that you can see what your code is doing at the same time as keeping an eye on how the robot is behaving e.g. which way is the sensor pointing, what is the reading, which wheel will be stopped.

Before you even run the robot you should just place objects in front of the sensor and convince yourself that you are getting resonably accurate distance readings and also accurate sensor angle readings.

Do not attempt to write the whole thing at once. You will end up with a lot of code that does not behave the way you expect and with no idea where to start looking for problems. Instead build the sketch up bit by bit. You will trust that parts work and when you do something wrong you will spot it at the time.