Ask 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 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.

+5
Answers (1)
  1. 17 August, 15:17
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers