40.7k views
4 votes
While writing a program to regulate the speed of a self-driving car, you find that your software sometimes miscalculates the ideal car speed for city streets to be over 1500 MPH (nearly twice the speed of sound), when it should be approximately 30 MPH. Which of the following strategies would be most efficient to employ in debugging your program?

A) At the very end of the speed calculations, add an additional line of code that divides the calculated speed by 50 so that the program never produces such high speeds
B) After each calculation within your program, insert a temporary statement that displays the most recently calculated value. When running your program, compare the displayed values with the expected values to identify where in the program the error is being introduced.
C) Starting at the end of your program and working backwards, systematically delete each line of code that relates to calculating and re-run the program after each deletion to identify where in the program the error is being introduced
D) Delete all of the code relating to speed calculations and rewrite it again

1 Answer

4 votes

Answer:

A)

Step-by-step explanation:

The answer would be (A) because if you read the other choices it doesn't make sense. (well to me?)

I'm truly sorry if I got you wrong.

User Flowerpowerdad
by
3.7k points