Ask Question
18 May, 05:38

Write a multi-way if/else statement that adds 1 to the variable reverseDrivers if the variable speed is less than 0, adds 1 to the variable parkedDrivers if the variable speed is less than 1, adds 1 to the variable slowDrivers if the variable speed is less than 40, adds 1 to the variable safeDrivers if the variable speed is less than or equal to 65, and otherwise adds 1 to the variable speeders.

+4
Answers (1)
  1. 18 May, 08:29
    0
    Code in jа vascript.

    Preconditions:

    All the variables are defined and initialized.

    if (speed < 0) { / / if speed is < 0 then adds 1 to reverse drivers.

    reverseDrivers + +;

    } else if (speed < 1) { / / else if speed is < 1 then adds 1 to parked drivers.

    parkedDrivers + +;

    } else if (speed < 40) { / / else if speed is < 40 then adds 1 to slow drivers.

    slowDrivers + +;

    } else if (speed < = 65) { / / else if speed is < = 65 then adds 1 to safe drivers.

    slowDrivers + +;

    } else { / / else if speed is > 65 then adds 1 to speeders.

    speeders++;

    }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Write a multi-way if/else statement that adds 1 to the variable reverseDrivers if the variable speed is less than 0, adds 1 to the variable ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers