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.

Respuesta :

Answer:

Code in Javascript.

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++;

}

ACCESS MORE